INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Play/Pause with hotkey  (Read 4238 times)

mikeza

  • Recent member
  • *
  • Posts: 39
Play/Pause with hotkey
« on: March 22, 2016, 01:56:33 pm »

Right now I'm using awesome window manager so my hotkeys are mostly implemented via command line calls but it appears the linux version does not support the command-line commands. What is the best way to get play/pause support working with hotkeys on linux?

Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5242
  • "Linux Merit Badge" Recipient
Re: Play/Pause with hotkey
« Reply #1 on: March 22, 2016, 02:44:59 pm »

MCWS is the best way to handle automation for MC on Linux.  If you navigate to localhost:52199 on the machine running MC, you can find the MCWS documentation (it's self documenting).

For some examples of bash scripting using MCWS, check out my notification script: https://yabb.jriver.com/interact/index.php?topic=99309.0

EDIT: Link fixed, thanks Brian!
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Play/Pause with hotkey
« Reply #2 on: March 22, 2016, 02:47:54 pm »

Don't user defined keys work in the Linux version?

https://wiki.jriver.com/index.php/User_Defined_Global_Keyboard_Shortcuts

They work on the Mac version, so I assumed they had a high chance of working well in Linux also.

BTW Mwillems I think your link isn't the one you meant to post.

Brian.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5242
  • "Linux Merit Badge" Recipient
Re: Play/Pause with hotkey
« Reply #3 on: March 22, 2016, 02:55:48 pm »

Don't user defined keys work in the Linux version?

https://wiki.jriver.com/index.php/User_Defined_Global_Keyboard_Shortcuts

They work on the Mac version, so I assumed they had a high chance of working well in Linux also.

BTW Mwillems I think your link isn't the one you meant to post.

Brian.

Those rely on MCC commands don't they?  I thought those weren't supported on non-windows platforms?  Are you saying that the core command automation works on Mac? If so, I can hold out hope it will come to Linux  ;D

Additionally, I'm not sure how well even the built in keyboard shortcuts work in Linux when the window isn't focused.  I'll have to test, but when I last fiddled with them (a very long time ago) they didn't work well.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Play/Pause with hotkey
« Reply #4 on: March 22, 2016, 03:11:56 pm »

Those rely on MCC commands don't they?  I thought those weren't supported on non-windows platforms?  Are you saying that the core command automation works on Mac?

Well, not exactly as I think you're thinking of doing something like MC.exe /MCC 20001 right?  The user defined keys are done inside of a Resource.xml file that specifically maps keys.  Here's a portion of the one I use on MC for Mac:

Code: [Select]
<!-- DSP Studio -->
<Entry Key="Ctrl;D" Command="10016" Param="0" />
<!-- Play/Pause -->
<Entry Key="Space" Command="10000" Param="0" TranslateFlags="21" />
<!-- Next and Previous track -->
<Entry Key="Ctrl;Right" Command="10003" Param="2" TranslateFlags="21" />
<Entry Key="Ctrl;Left" Command="10004" Param="2" TranslateFlags="21" />
<!-- Show Now Playing -->
<Entry Key="Ctrl;N" Command="10013" Param="1" />

As you can see, they specifically use MCC command numbers, but it's called via the "entry key" commands and not through an MC.exe command line.

Quote
Additionally, I'm not sure how well even the built in keyboard shortcuts work in Linux when the window isn't focused.  I'll have to test, but when I last fiddled with them (a very long time ago) they didn't work well.

As I understand it, none of the keys that are mapped into MC (manually or built in) are functional unless the window is focused.  If you want truly global key mappings, then I guess your solution of using MCWS and some kind of scripting and integration with the window manager is probably a better solution.

Brian.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5242
  • "Linux Merit Badge" Recipient
Re: Play/Pause with hotkey
« Reply #5 on: March 22, 2016, 09:05:00 pm »

Well, not exactly as I think you're thinking of doing something like MC.exe /MCC 20001 right?  The user defined keys are done inside of a Resource.xml file that specifically maps keys.  Here's a portion of the one I use on MC for Mac:

Code: [Select]
<!-- DSP Studio -->
<Entry Key="Ctrl;D" Command="10016" Param="0" />
<!-- Play/Pause -->
<Entry Key="Space" Command="10000" Param="0" TranslateFlags="21" />
<!-- Next and Previous track -->
<Entry Key="Ctrl;Right" Command="10003" Param="2" TranslateFlags="21" />
<Entry Key="Ctrl;Left" Command="10004" Param="2" TranslateFlags="21" />
<!-- Show Now Playing -->
<Entry Key="Ctrl;N" Command="10013" Param="1" />

As you can see, they specifically use MCC command numbers, but it's called via the "entry key" commands and not through an MC.exe command line.

That's super neat, thanks for calling that to my attention.  I just assumed that wouldn't work because the MCC command line wasn't supported.

Quote
As I understand it, none of the keys that are mapped into MC (manually or built in) are functional unless the window is focused.  If you want truly global key mappings, then I guess your solution of using MCWS and some kind of scripting and integration with the window manager is probably a better solution.

Brian.

I was assuming OP wanted global shortcuts as, if the window is focused, you can play or pause just by pressing the spacebar out of the box on all platforms.  So I was (perhaps erroneously) assuming he was looking for something more like a media key on a keyboard that would work no matter what he was doing otherwise.  He can fill us in on what he needs  ;)
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Play/Pause with hotkey
« Reply #6 on: March 22, 2016, 09:20:08 pm »

That's super neat, thanks for calling that to my attention. 

It's a good day when I can help you out.  :)

Quote
I was assuming OP wanted global shortcuts as, if the window is focused, you can play or pause just by pressing the spacebar out of the box on all platforms.

This is worth expounding upon, because it just bugged me like CRAZY when I first got MC running.  Yes, spacebar does Play/Pause in MC.  But not always.  ...and it's not obvious why until you play around with it.  Essentially, MC only does play/pause with spacebar when the focus is in the playing now pane, or in one of file display areas, or in a category.  It will NOT do play/pause when you are focused on the navigation tree on the left, the search area, and perhaps a few others.

This promotes a very inconsistent interface experience, as you wonder, "why the hell isn't spacebar working?!??"  Apparently spacebar can be used for navigation tasks too.  Like expanding tree segments.  This is stupid and should be changed.  But it's not likely to be changed because it has history.

My key mapping above addresses this by overriding the default behavior of spacebar in almost all areas of MC's interface.  *Except* for text entry boxes where you probably want to be able to type a space!  Getting this working was really nice.  After all, pretty much every audio player in existence uses spacebar for play/pause and it's generally not context sensitive, except for places where you'd want to type a literal space.

The key is the TranslateFlags parameter.

Brian.
Logged

mikeza

  • Recent member
  • *
  • Posts: 39
Re: Play/Pause with hotkey
« Reply #7 on: March 24, 2016, 12:37:44 pm »

Thanks a bunch guys. The intent was for global shortcuts, yes. I'll have to spend some time delving into the media server interface. I'll post back when I make some progress!
Logged
Pages: [1]   Go Up