INTERACT FORUM

Please login or register.

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

Author Topic: Query player "mode" via automation?  (Read 3624 times)

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Query player "mode" via automation?
« on: September 19, 2009, 11:09:43 pm »

Hi. I'm trying to write a script to query the current "mode" MC is in (ie, Standard View, Display View, Theater View etc) but I can't find a suitable automation call to do it.

Anyone know if this can be done?

Cheers.
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

muchadhesion

  • Recent member
  • *
  • Posts: 44
Re: Query player "mode" via automation?
« Reply #1 on: September 20, 2009, 10:37:49 am »


I don't know specifically how to do what you are asking, but the info below might be useful?

I long ago reached the limit of what the official plug-in API can do - but I discovered that MC stores a lot of "live" and persisted settings in the registry.

HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Properties
HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Player Core
HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Playback Engine

Reading and writing to these gets you some additional tools to integrate with MC.

You might find the "View Mode" is in their somewhere.  (Caveat: All of this is undocumented, and presumably subject to changing on JR's whim.)
Logged

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #2 on: September 21, 2009, 05:34:09 am »

Hmm, I found a reg key called "Last UI Mode" under HKEY_CURRENT_USER\Software\JRiver\Media Center 13\Properties but this value is only updated when the app is closed rather than between UI mode transitions. So close yet so far....

I'll keep searching but it's not looking good. Thanks for the suggestion though.
 
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #3 on: September 21, 2009, 08:27:42 pm »

JRiver (Matt?) - would it be possible please to update this reg key on each view mode change? Extending the API to query the current view mode would be the ultimate but I'm assuming the reg change would be simpler to implement and serve me just as well.

Thanks in advance.
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Query player "mode" via automation?
« Reply #4 on: September 22, 2009, 02:42:09 am »

i would also like this very much, and i think the api is the right place.
an event when switching mode? where string3 tells to which mode the switch is made?

 :)
gab
Logged

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #5 on: September 25, 2009, 06:32:52 am »

an event when switching mode? where string3 tells to which mode the switch is made?

Hmmmm, I never considered this. By event, do you mean one of the MCC_NOTIFY notifications? Would the existing MCC_NOTIFY_VIEW_CHANGED (34001) do the trick? Sorry, I'm not too sure if I'm on the right track with this. If this worked, how would I use it?
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Query player "mode" via automation?
« Reply #6 on: September 25, 2009, 06:55:40 am »

guess not, i just tried, but like these events: http://wiki.jrmediacenter.com/index.php/Media_Center_Automation#Event_Handling
and when i switch to thv, there is no event fired what so ever. but ofcource there might be a way to catch those mcc notifications. i have no idea, but when you find it, it would be great to know.

 :)
gab
Logged

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Query player "mode" via automation?
« Reply #7 on: October 15, 2009, 05:18:50 am »

did you find a solution?
ive been trying to use the findwindow and findwindowex functions, but without succes.
does someone else have a suggestion?

 :)
gab
Logged

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #8 on: February 02, 2010, 03:09:38 am »

did you find a solution?

Sorry for the late reply. Unfortunately, no. This is still something I'm trying to resolve.

JRiver, any chance of adding this capability please? Even the registry idea discussed above would be fine if it's easier to implement.

Thanks.
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #9 on: April 06, 2010, 11:20:46 pm »

*BUMP*

JRiver, any chance of adding this capability please? Even the registry idea discussed above would be fine if it's easier to implement.

Maybe for MC15 please? .....

Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

raldo

  • Citizen of the Universe
  • *****
  • Posts: 1102
Re: Query player "mode" via automation?
« Reply #10 on: April 07, 2010, 04:30:50 am »

*BUMP*
Maybe for MC15 please? .....

Raym,

while we're waiting for changes to the plugin API (!) here's a method you can use, I believe, to detect if the display view and theater view windows are active.

This is similar to what Gappie is proposing above. The "WindowEnumProc" function will iterate through all child views of the JRiver main wndow and "Display", "Theater[]" can thus be used to detect the mode.

Cumbersome, yes...


Code: [Select]
        public delegate bool WindowEnumDelegate(IntPtr hwnd, int lParam);

        // declare the API function to enumerate child windows
        [DllImport("user32.dll")]
        public static extern int EnumChildWindows(IntPtr hwnd, WindowEnumDelegate del, int lParam);
        [DllImport("user32.dll")]
        static extern int GetForegroundWindow();
        [DllImport("user32.dll")]
        public static extern int GetWindowText(IntPtr hwnd, StringBuilder bld, int size);
        [DllImport("user32.dll")]
        public static extern int GetWindowRect(IntPtr hwnd, ref Rectangle lpRect);
        [DllImport("user32.dll")]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        //[DllImport("user32.dll")]

        Graphics g = null;

        private void timer1_Tick(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder (256);
            IntPtr handle = (IntPtr) mcRef.GetWindowHandle();

            // instantiate the delegate
            WindowEnumDelegate del
                   = new WindowEnumDelegate(WindowEnumProc);

            // call the win32 function
            Debug.WriteLine("-----------------------------------------");
            EnumChildWindows(handle, del, 0);
           
        }

        static IntPtr hwndDisplay;
        public static bool WindowEnumProc(IntPtr hwnd, int lParam)
        {
            // get the text from the window
            StringBuilder bld = new StringBuilder(256);
            GetWindowText(hwnd, bld, 256);
            string text = bld.ToString();

            if (text.Length > 0)
                if (text == "Display")
                    //if (text == "JRiver Display Window")
                    hwndDisplay = hwnd;

            return true;
        }


Logged

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #11 on: April 08, 2010, 08:09:44 am »

Thanks Raldo. This looks a little beyond me (I'm more of your "coder by example" kind of guy). I'll take a closer look at it tonight though.
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

raldo

  • Citizen of the Universe
  • *****
  • Posts: 1102
Re: Query player "mode" via automation?
« Reply #12 on: April 08, 2010, 04:05:15 pm »

Thanks Raldo. This looks a little beyond me (I'm more of your "coder by example" kind of guy). I'll take a closer look at it tonight though.
Well, it's a code example, so go for it :)!
Logged

Mike Noe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 792
Re: Query player "mode" via automation?
« Reply #13 on: April 26, 2010, 01:32:32 pm »

Not sure if this helps, but I use the following to determine if THV has focus:

Code: [Select]
; Look for the Theater View or Display View using Visible Text Keyword
ifWinExist, ahK_Class MJFrame, Display
 {
  WinWaitNotActive  ; Wait until MC loses focus
  ifWinNotExist, ahk_class JRiver Menu Class  ; If it's not the THV menu, set focus back to MC
   WinActivate
 }
 else
 {
  WinWait, ahK_Class MJFrame , Display  ; If Display or THV not found, wait for it to show up
 }

And I am using this to determine "Display" mode (I'm not sure this works in v15):

Code: [Select]
MC_IsInDisplayMode() {
  Save := A_DetectHiddenText
  nRet := -1
  DetectHiddenText off
  ifWinExist,, JRiver Report Control
    nRet := False
  Else
    nRet := True
  DetectHiddenText, %Save%

  Return nRet
Logged
openSUSE TW/Plasma5 x86_64 | Win10Pro/RX560
S.M.S.L USB-DAC => Transcendent GG Pre (kit) => Transcendent mono OTLs (kit)
(heavily modded) Hammer Dynamics Super-12s (kit)
(optionally) VonSchweikert VR8s

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Query player "mode" via automation?
« Reply #14 on: May 12, 2010, 12:18:24 pm »

In 15.0.41 and later:
Changed: Added command MCC_QUERY_UI_MODE (32000) to allow querying the user interface mode of the program from a batch file.
Changed: MC15.exe is a console application so it's easier to use in batch files or with other scripting.
Changed: MC15.exe /MCC will exit the process with the result of the call. (so in a batch file, %ERRORLEVEL% will be the result after a call)
Logged
Matt Ashland, JRiver Media Center

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Query player "mode" via automation?
« Reply #15 on: May 16, 2010, 07:44:55 pm »

In 15.0.41 and later:
Changed: Added command MCC_QUERY_UI_MODE (32000) to allow querying the user interface mode of the program from a batch file.
Changed: MC15.exe is a console application so it's easier to use in batch files or with other scripting.
Changed: MC15.exe /MCC will exit the process with the result of the call. (so in a batch file, %ERRORLEVEL% will be the result after a call)


Matt, thanks again for adding this. I think build 42 removed the second two changes though right? I don't think it matters much (to me at least) and for anyone who's interested, here's a VERY simple batch script example to show how to use this new query to do something based on whether MC is in Theater View or not:

Code: [Select]
@ECHO OFF

REM --- Look for Theater View
MC15.exe /MCC 32000 | find "3"

IF %ERRORLEVEL% == 0 GOTO TheaterView

:NotTheaterView
REM --- Do something
EXIT

:TheaterView
REM --- Do something Theater View specific
EXIT


Thanks again!
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: Query player "mode" via automation?
« Reply #16 on: May 18, 2010, 02:05:21 am »

thanks for adding this.. 8)
Logged
Pages: [1]   Go Up