[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27) +---- Forum: Service Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=152) +---- Thread: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) (/showthread.php?tid=151011) |
RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-11-11 (2015-11-11, 12:44)schumi2004 Wrote: Would it be possible to have this script to react on certain addon actions only? As stated many times in this thread: The only events that can be easily coded are those built into the Python api (see Monitor and Player sections): see http://mirrors.kodi.tv/docs/python-docs/15.x-isengard/xbmc.html#Monitor So in short, no, plugin starts and stops cannot be used as triggers. The long version is: IF Retrospect uses the builtin player AND this Addon detects starts and stops you can try to detect that whatever was playing was a Retrospect stream by looking at whatever info the addon puts out about whatever was playing - i.e. 'playing type' should be stream. Or edit the Retrospect Plugin calling your script on starts and stops. I don't use that Plugin so I can't test for you. Unfortunately developing something specific like this requires several hours of coding and testing and I just don't have the time. If you have any python experience at all, start with looking if you can create a monitor loop with the JSON api. I would do a JSON introspect to start and see if there is anything about plugin starts and stops. If nothing looks promising there (doubtful there is, but always worth a shot), look in the kodi log and see if there is anything that uniquely identifies that plugin's starts and stops. If so, the messy hack is to write a loop that constantly reads in the last few lines of the log and then check if there is a regex match for the 'signature' of either the start or stop of your plugin. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - kulgan - 2015-11-19 Hi, I'm currently moving from openelec 5 to 6. My hardware is RPI2. On openelec 6 RestartApp buildin command stay stuck . In log I can found : 22:25:35 2513.399902 T:1699738688 WARNING: CPythonInvoker(5): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour wi 22:25:35 2513.418945 T:1699738688 NOTICE: $$$ xbmc.callbacks2 - Starting tester.py from cwd: /storage/.kodi/addons/service.xbmc.callbacks2 22:25:36 2514.286377 T:1699738688 NOTICE: $$$ [xbmc.callbacks2] - Executing command: [RestartApp] for event: onScreensaverActivated 22:25:36 2514.287109 T:1699738688 NOTICE: $$$ [xbmc.callbacks2] - Command for onScreensaverActivated resulted in ERROR: None 22:25:36 2514.313965 T:1968070656 NOTICE: Storing total System Uptime 22:25:36 2514.314697 T:1968070656 NOTICE: Saving settings 22:25:36 2514.341309 T:1968070656 NOTICE: stop all 22:25:36 2514.341553 T:1968070656 NOTICE: stop player 22:25:36 2514.341553 T:1968070656 NOTICE: ES: Stopping event server 22:25:36 2514.642822 T:1968070656 NOTICE: stopping upnp 22:25:36 2514.899414 T:1968070656 NOTICE: stopping zeroconf publishing 22:25:36 2514.905273 T:1968070656 NOTICE: Webserver: Stopping... 22:25:36 2514.905762 T:1968070656 NOTICE: WebServer: Stopped the webserver 22:25:36 2514.906006 T:1968070656 NOTICE: Webserver: Stopped... 22:25:37 2515.297607 T:1624241216 NOTICE: ES: UDP Event server stopped 22:25:37 2515.298340 T:1968070656 NOTICE: stop dvd detect media 22:25:37 2515.932129 T:1968070656 NOTICE: stop sap announcement listener 22:25:37 2515.932129 T:1968070656 NOTICE: clean cached files! 22:25:37 2515.932373 T:1968070656 NOTICE: unload skin 22:25:37 2516.051270 T:1806136384 NOTICE: ## OpenELEC Addon ## STOP SERVICE DONE ! 22:25:38 2516.177734 T:1682961472 NOTICE: $$$ [xbmc.callbacks2] - Stopped xbmc.callbacks2 22:25:43 2521.209229 T:1968070656 ERROR: CPythonInvoker(5, /storage/.kodi/addons/service.xbmc.callbacks2/tester.py): script didn't stop in 5 seconds - let's kill it how to investigate/fix this ? I've tried to run in a terminal : kodi-send --action="XBMC.RestartApp"; result is OK. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-11-20 It's hard to say bc that looks like an ok termination log. The 'let's kill it' actually occurs for many addons and in this instance it is from the testing screen, so I am not sure if that is the issue. Can you verify that kodi remains running in memory and does not restart after using this trigger from an actual screensaver event, not from the testing screen? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - kulgan - 2015-11-20 Hi, Yes, same issue if using screensaver event RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-11-21 (2015-11-20, 23:03)kulgan Wrote: Hi, On windows, it kills Kodi, but doesn't restart it. Even running a three line script as a 'Program' that executes that builtin causes the same behavior, so I think there may be a problem with the way Kodi multithreads the scripts and having that command execute correctly. Sorry. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - GriffeyJuni0r - 2015-11-22 Any way to have an option for "Every Other Play Start" event? I basically want something to fire every other time something gets played. Thanks! RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - nickr - 2015-11-22 Create a script that flips a variable when it runs, and then only continues if the variable is on. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - nickr - 2015-11-22 Create a script that flips a variable when it runs, and then only continues if the variable is on. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - GriffeyJuni0r - 2015-11-22 Genius - that works great, thanks! RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-11-22 I was going to suggest a similar solution but nickr beat me to it. Because each run won't leave a simple way to access a memory stored variable, I would create and destroy a token file. Something like: Code: import xbmc, xbmcvfs Disclaimer: I didn't actually test this code yet RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - midgetspy - 2015-11-30 FYI I've forked pilluli's original repo and changed it up to suit my own needs: https://github.com/midgetspy/service.xbmc.callbacks Basically now it calls a single script and provides arguments to indicate what event is happening. It now supports some more info about the video playing as well (3D mode, aspect ratio). Hope it's useful to somebody :0) A sample callback script is available in resources/lib/. EDIT: Looks like maybe I just re-did KenV99's work. Ah well, shoulda read the thread more carefully before I forked ;-P RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - Livin - 2015-12-03 (2015-11-30, 08:37)midgetspy Wrote: FYI I've forked pilluli's original repo and changed it up to suit my own needs: https://github.com/midgetspy/service.xbmc.callbacks I'm not sure I follow after your Edit... can you explain what you've added / changed? I've never used Ken's but I just started looking at possibly using it. thx RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - midgetspy - 2015-12-03 I've added some more info in the readme: https://github.com/midgetspy/service.xbmc.callbacks/blob/master/README.md RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - JANGER - 2015-12-03 Great news! Thank you. I use your scripts to send http messages which control the lights in my cinema. Depending on the content and event type, I change color brightness or the speed of dimming. (When the movie starts all lights are dimming smoothly for few seconds) One more dream: I would like to play THX trailer video prior to each movie starts. I hate Cinema Experience (it does not work with all skins, and not start automatically). I hate CinemaVision even more, it has too many feature. We need just the one: play selected video prior to the movie start event. Have you any idea? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-12-04 (2015-12-03, 11:34)JANGER Wrote: Great news! Thank you. You would need to call your script as a python script in the kodi namespace. A brief outline of what you would do: 1) Subclass xbmc.player 2) Detect if a movie is playing using xbmc.getCondVisibility('VideoPlayer.Content(movies)') or by parsing the arguments by xbmc.callbacks2 3) Detect if you have a trailer to play and it's location 4) If so, store the name of the current playing file, stop playing, start playing trailer 5) Use xmbc.player onPlaybackEnded event to catch when the trailer is over and then restart the original file Unfortunately, I don't have the time to write it out in code. Good luck! |