INTERACT FORUM

Please login or register.

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

Author Topic: Start userdefined script on videoplayback  (Read 1766 times)

((( atom )))

  • Recent member
  • *
  • Posts: 40
Start userdefined script on videoplayback
« on: October 18, 2021, 11:06:54 am »

Hi,

wondering, if there is a mechanism to start a userscript upon start of video playback, which will pass some information about the videofile to the userscript.

I'm looking for a way to control my projector (High/Low Lamp mode for SDR/HDR, shifting of the image and so on).

Any hints would be very welcome.
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Start userdefined script on videoplayback
« Reply #1 on: October 19, 2021, 10:59:51 am »

Hi,

wondering, if there is a mechanism to start a userscript upon start of video playback, which will pass some information about the videofile to the userscript.

I'm looking for a way to control my projector (High/Low Lamp mode for SDR/HDR, shifting of the image and so on).

Any hints would be very welcome.

So, I'm not sure there's a way to "push" the info out, but you can write a script that polls JRiver and pulls that information via the MCWS automation framework. It's self-documenting, but there's a wiki article here:  https://wiki.jriver.com/index.php/Web_Service_Interface.

You can pull almost any information about what's going on in JRiver via MCWS.  Basically you'd want a script running in the background that polls for changes in playstate, and then when video playback is started, you can trigger other changes you have in mind.
Logged

((( atom )))

  • Recent member
  • *
  • Posts: 40
Re: Start userdefined script on videoplayback
« Reply #2 on: October 19, 2021, 01:58:54 pm »

Thx for the hint but I don't want to have 10.000 polls run through an evening. Is there nothing that would allow for some use-defined scripting? Any plugin maybe?
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72442
  • Where did I put my teeth?
Re: Start userdefined script on videoplayback
« Reply #3 on: October 19, 2021, 02:06:16 pm »

Thx for the hint but I don't want to have 10.000 polls run through an evening. Is there nothing that would allow for some use-defined scripting? Any plugin maybe?
Polling wouldn't be a heavy load.

Have you found the DevZone?  Link at the bottom.  Start at MCWS.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4231
Re: Start userdefined script on videoplayback
« Reply #4 on: October 19, 2021, 03:14:31 pm »

Polling wouldn't be a heavy load.
It is inefficient, chatty and relatively slow (laggy). It would be great if MC had some websocket (or similar) broadcast mechanism instead
Logged

((( atom )))

  • Recent member
  • *
  • Posts: 40
Re: Start userdefined script on videoplayback
« Reply #5 on: October 20, 2021, 05:10:44 am »

Of course polling is not a heavy load processor-wise, but it is ugly, not on-point responsive and can get really messy. Been there with kodi. Once I switched to interrupt-based events via a plugin, things started working like a charm. It is a very big difference, if my roomlight turns on somewhen after I pres pause or the very moment I do so. The former feels like, ok, cool, the later like it is just built into the machine.

I threw out all polling I could from every machine around my house. Really tightened things up.

The Web Service Interface itself looks promising for general control, though. A very important part for me as well, so thanks for the hint.
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p

max096

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 363
Re: Start userdefined script on videoplayback
« Reply #6 on: October 20, 2021, 08:45:56 am »

It is inefficient, chatty and relatively slow (laggy). It would be great if MC had some websocket (or similar) broadcast mechanism instead

Would be great! Also to improve jrivers own responsiveness when streaming media things don't appear everywhere immediately when you make changes to anything.
But currently you can't get around polling with MCWS. Local polling playback info every second or so should not be a massive problem. And the second you are on in your playback you can calculate to keep 'smooth' if you need it. So the long polling interval mostly limits immediate responsiveness of a state change.

Currently setting up Home Assistant at home thought about maybe writing some JRiver integration either for Home Assistant directly or MQTT. Probably will go the MQTT route because it's easier (I think) and more compatible beyond Home Assistant. Personally more interested in playback info for music. Playing or not Playing and song information but it might just be actually the same for videos. Not sure when I'll get around to do that though, might be a while. Can't promise anything.

About getting around the delay entierly the only options I can think off at the moment are either to put a proxy in front of MCWS that handles state changes immediately (though ofc you are then limited to also controlling it threw mcws with jremote or another JRiver, so not perfect). Or find some way to do this with a JRiver plugin. Maybe you can listen to state changes there. Most likely I will not go down either of those paths.
Logged

((( atom )))

  • Recent member
  • *
  • Posts: 40
Re: Start userdefined script on videoplayback
« Reply #7 on: October 20, 2021, 12:35:55 pm »

Up until now I use a plugin for Kodi, that can run user-defined actions upon defined events. For instance it can send a http-request when a video starts playing. That is how I currently control my lights in the room. It's neat: When I press PAUSE on my remote, it is as if I pressed the lightswitch as well.
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p

max096

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 363
Re: Start userdefined script on videoplayback
« Reply #8 on: October 20, 2021, 05:12:26 pm »

Up until now I use a plugin for Kodi, that can run user-defined actions upon defined events. For instance it can send a http-request when a video starts playing. That is how I currently control my lights in the room. It's neat: When I press PAUSE on my remote, it is as if I pressed the lightswitch as well.

Is figuring out wether or not MC plays a video or not after you pressed the button an option for you? Calling MCWS/v1/Playback/Info for instance roughly takes 40-45ms for me to complete. Not sure if that alone spits out all you need.
Logged

((( atom )))

  • Recent member
  • *
  • Posts: 40
Re: Start userdefined script on videoplayback
« Reply #9 on: October 20, 2021, 06:19:52 pm »

That was my first method of figuring out, if Kodi was playing or not. Worked, of course, but as I said, I was very happy to switch over to Interrupts, so going back to this would be a step back. Will do only, if there really is no other option.
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p

((( atom )))

  • Recent member
  • *
  • Posts: 40
Re: Start userdefined script on videoplayback
« Reply #10 on: October 21, 2021, 04:03:42 pm »

Would be a charm, having a simple shell script with all the variables prefilled, like resolution, ar, audio tracks and so on. With that at hand, one could really built most things that come to mind with no effort.
Logged
Debian 11 Bullseye - Nvidia 1050 Ti with 4GB RAM - X11@4K24p
Pages: [1]   Go Up