If your media keys send ACPI events, you could use
acpid to act on them.
Unfortunately, it requires global config changes (instead of per-user), and it might be tricky to communicate the events to your X11 applications.
You can see what ACPI events, if any, are sent by your media keys by running
acpi_listen and then pressing those keys. For example, this appears in
acpi_listen output when I press "brightness up" key on my laptop:
video/brightnessup BRTUP 00000086 00000000
If your keys do send ACPI events, you can configure
acpid to run a command when they're pressed. The relevant configuration files are usually found in
/etc/acpi/events/. They can have any name, as long as they're in the right directory. They look like this:
The first line constains
event= followed by a regex to match the ACPI events. If an event matches the regex, the command specified in the second lin (after
action=) is executed. The
%e is expanded to the event line. In this case, it's used to pass the event as commandline arguments to the script.
There's also a nice article about
acpid on Arch Wiki: https://wiki.archlinux.org/index.php/Acpid
The next step would be to figure out how to control your media player from a script.