INTERACT FORUM

Please login or register.

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

Author Topic: Ways to control MediaCenter ?  (Read 4611 times)

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Ways to control MediaCenter ?
« on: June 03, 2021, 08:55:28 am »

I'm not planning to program a plug-in. I'm looking for API's to control MC.

So far I used MCC Commands and Keyboard Commands. Some commands as Play/Pause are available in both. Others like "/Append selected" are available as Command Line Commands only. And to navigate through views I have to send Keyboard codes like Cursor Up/Dn.

As long as MC is the active Application (in front) it works well. But as soon another application (on a different monitor) is active it becomes complicated. Keyboard commands are then interpreted from the 'wrong' application. Until you find out, that 'Backspace' does nothing in TheaterView, you might have deleted a lot somewhere else.

I built a Media keyboard with the only purpose to control MediaCenter like a CD carousel without a mouse, keyboard or touch. Until now, it is acting as a USB HID Keyboard. The key handling is defined in Resource.XML

Alternatively the Media keyboard could communicate through VirtualComPort (CDC) with a Win10 application. And this application should be able to control MC even it is in background.


Question:
How can I send a keycode to MC when it is in background, without bringing it in front ?
Is it possible to call the functions associated with keyboard or menu actions directy ?

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2616
Re: Ways to control MediaCenter ?
« Reply #1 on: June 03, 2021, 10:59:07 am »

You can try a tool to send keypresses to another process. there are many, here's a very simple one:
https://github.com/awaescher/SendKeys

Looks like this one only works with a PID, but I'm sure there are others out there take take a process name.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Ways to control MediaCenter ?
« Reply #3 on: June 04, 2021, 01:21:26 am »

Thank you both for the hints. But they might not help.
The SendKey approach internally uses 'System.Windows.Forms.SendKeys.SendWait' which always goes to the top window. To overcome this, the program brings the targeted application to front. Any other keyboard entry would go to MC too.

The usage of webservices would be preferred. But I cannot find commands to navigate and scroll through views. Did I miss something?

The 6 buttons in the bottom row control playback. Webservices or MCC core commands would work for this.
'INSERT', 'APPEND' adds selected items to 'playing now'. This is done by command line commands '/PlayNext selected' and '/Append selected'

Four cursor buttons are for navigating. Two buttons for Enter and Backspace.  Here I miss a similar possibility. Is there no MCC Command which allows to inject keystrokes to MC ?
Do Plugins have access to such functions ?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2616
Re: Ways to control MediaCenter ?
« Reply #5 on: June 04, 2021, 06:00:01 am »

Wouldn't you want MC to be in the foreground anyway when navigating the menus/views?
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Ways to control MediaCenter ?
« Reply #6 on: June 05, 2021, 05:28:38 am »

Maybe something like this?

https://stackoverflow.com/questions/8953399/c-sharp-sendkeys-sendwait-works-only-when-processes-window-is-minimzed?rq=1

This application uses "SetForegroundWindow". Once executed. MC is the OnTop application an receives all keys.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Ways to control MediaCenter ?
« Reply #7 on: June 05, 2021, 05:39:29 am »

Wouldn't you want MC to be in the foreground anyway when navigating the menus/views?

You're right if you think of a single monitor equipment. I'm running MC in TheaterView on a smaller monitor on my desk. It is not always obvious which application is 'on top'. Sending PgUp and Backspace to the wrong application, i.e an code editor, can cause troubles.


Is the IR remote programmed as plugin ? Is this source code available ? IR commands can be mapped to Navigation keys. This is what I need.
Logged

Inquisition

  • World Citizen
  • ***
  • Posts: 216
Re: Ways to control MediaCenter ?
« Reply #8 on: June 06, 2021, 02:50:14 am »

For Scroll and Navigation:



End                  http://localhost:52199/MCWS/v1/Control/Key?Key=End&Focus=1
Home                http://localhost:52199/MCWS/v1/Control/Key?Key=Home&Focus=1
Page Up            http://localhost:52199/MCWS/v1/Control/Key?Key=Page Up&Focus=1
Page Down        http://localhost:52199/MCWS/v1/Control/Key?Key=Page Down&Focus=1

Left                  http://localhost:52199/MCWS/v1/Control/Key?Key=Left&Focus=1
Right                http://localhost:52199/MCWS/v1/Control/Key?Key=Right&Focus=1
Up                   http://localhost:52199/MCWS/v1/Control/Key?Key=Up&Focus=1
Down               http://localhost:52199/MCWS/v1/Control/Key?Key=Down&Focus=1
Back                http://localhost:52199/MCWS/v1/Control/Key?Key=Backspace&Focus=1
Enter OK          http://localhost:52199/MCWS/v1/Control/Key?Key=Enter&Focus=1


If you have more Zones you need to put them into command like example few posts before.
This way you should be able to send every keyboardorder with one ore more types you want.   An Example from my Remote for madvr in jriver:   <key id="Profil 1080i" code="Control/Key?Key=Ctrl;Alt;Shift;Z&amp;Focus=1"/>


Should Work.

In my Mediolasystem they do!

    <key id="Nav Links" code="Control/Key?Key=Left&amp;Focus=1"/>                    
    <key id="Nav Rechts" code="Control/Key?Key=Right&amp;Focus=1"/>                 
    <key id="Nav Auf" code="Control/Key?Key=Up&amp;Focus=1"/>                       
    <key id="Nav Ab" code="Control/Key?Key=Down&amp;Focus=1"/>                    
    <key id="Seite Auf" code="Control/Key?Key=Page Up&amp;Focus=1"/>                 
    <key id="Seite Ab" code="Control/Key?Key=Page Down&amp;Focus=1"/>                 
    <key id="Nav Zurueck" code="Control/Key?Key=Backspace&amp;Focus=1"/>              
    <key id="Enter / OK" code="Control/Key?Key=Enter&amp;Focus=1"/>

and so on....

I have over 300 commands in my remote system this way.
Logged
My English is not perfect, so be merciful with me

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Ways to control MediaCenter ?
« Reply #9 on: June 06, 2021, 06:22:03 am »

Thanks! This is it.
Wheaten pointed this way. But I didn't see the 'Key' feature.

One question left: How to add the selected item to Playing now ? For the command line there are three commands "/Append selected", "/PlayNext selected" and "/PlayReplace selected". How to call them by URL ?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2616
Re: Ways to control MediaCenter ?
« Reply #10 on: June 06, 2021, 07:31:05 am »

Search for "PlayMode" in the documentation. /Files/Current seems the best option.
http://localhost:52199/MCWS/v1/
Logged
Pages: [1]   Go Up