[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-09-13 (2015-09-13, 14:23)jknight2014 Wrote:Make sure you changed 'idledebug' and not 'debug' because that error indicates that you changed 'debug' because it is trying to invoke the pydevd debugger which I doubt you have installed. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-09-13 (2015-09-13, 14:10)trogggy Wrote: Quick question Ken - sorry if I've missed something, but should this be working on Helix? Sleep is not one of the triggers so I am at a loss there. If you try to use the 'on Shutdown' trigger, you may miss the change in screens because Kodi shuts down immediately after that event fires. Resume is only resume from playback being paused. I would doubt that you really want to show the home screen every time you resume playback after pausing. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - trogggy - 2015-09-13 (2015-09-13, 15:11)KenV99 Wrote: Sleep is not one of the triggers so I am at a loss there.Resume - sorry meant startup - I can see that's a red herring anyway, as it isn't starting up - it's waking up - and if starts from cold it's on the Home screen anyway. Sorry for the confusion there, my fault. I have the shutdown function configured to sleep rather than poweroff IYSWIM. So I'm sending a shutdown command in kodi, I'd have expected it to be on the home screen when it wakes. No? Edit: Just checked the log and (unsurprisingly) there's no mention of anything happening... Would it be possible to add sleep as a trigger to perform an action? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-09-13 (2015-09-13, 15:34)trogggy Wrote: Resume - sorry meant startup - I can see that's a red herring anyway, as it isn't starting up - it's waking up - and if starts from cold it's on the Home screen anyway. Sorry for the confusion there, my fault. Ok. The 'on Shutdown' event only fires when Kodi is actually shutting down (i.e. a Kodi abort has been requested). As far as how your system is 'sleeping' - do you mean in Settings -> System -> Power saving that you have set 'Put display to sleep on idle'? If so, you can try using the 'on Idle' trigger. That is the only 'sleep' setting that I am aware of in the standard build. There could be something specific to OpenELEC. If there is, then, no the only events that can be easily coded are those built into the Python api: see http://mirrors.kodi.tv/docs/python-docs/15.x-isengard/xbmc.html#Monitor RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - trogggy - 2015-09-13 No. What I've done is to map the shutdown function to 'suspend' in system > settings > power saving. That's a kodi core feature, not specific to openelec. My first attempt at this was to use 'on idle' and it triggered at strange times (eg mid-music). Not to worry - I've put together a shutdown (sleep) script and mapped it to a button, which does the same job. Edit: log snippet of what happens when I press 'clear' on the remote (read as delete, mapped to shutdown, which triggers suspend - bit convoluted, eh?) Code: 15:42:49 T:140711430465408 DEBUG: LIRC: Update - NEW at 89803:6f 0 KEY_DELETE devinput (KEY_DELETE) RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - jknight2014 - 2015-09-14 I got it working. A restart was required after changing the setting. However kodi is idle while playing a video. So it shuts the tv off during a show. Is that normal? RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-09-14 (2015-09-14, 03:18)jknight2014 Wrote: I got it working. A restart was required after changing the setting. However kodi is idle while playing a video. So it shuts the tv off during a show. Is that normal? That, indeed, is the default behavior of Kodi's xbmc.GetGlobalIdleTime function - it does not reset itself while playing a video or music. However, I think that it would be more useful to most if Kodi was not considered idle while playing as in your case and troggy's. So I made a few changes so that the idle timer does not start counting unless the player is not playing and pushed it to git hub. Let me know if it works for you. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - jknight2014 - 2015-09-14 (2015-09-14, 12:50)KenV99 Wrote: That, indeed, is the default behavior of Kodi's xbmc.GetGlobalIdleTime function - it does not reset itself while playing a video or music. It seems to be working great. Thanks! I agree playing video should not be idle. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - JANGER - 2015-10-04 I try to use it in RPi OSMC version. it does not work. I ssume it did not intialized propertly at all. have any idea how to fix? here is the log: 13:51:29 32.128613 T:1759802400 NOTICE: -->Python Interpreter Initialized<-- 13:51:31 33.935440 T:1503654944 NOTICE: Thread BackgroundLoader start, auto delete: false 13:51:31 34.173580 T:1503654944 NOTICE: Previous line repeats 1 times. 13:51:31 34.173836 T:1503654944 NOTICE: Thread JobWorker start, auto delete: true 13:53:06 128.746902 T:1470100512 NOTICE: Thread LanguageInvoker start, auto delete: false 13:53:06 128.748657 T:1717335072 NOTICE: Thread JobWorker start, auto delete: true 13:53:07 129.354507 T:1470100512 NOTICE: -->Python Interpreter Initialized<-- 13:53:14 136.895264 T:1470100512 NOTICE: Thread BackgroundLoader start, auto delete: false 13:53:25 147.743332 T:1528820768 NOTICE: Previous line repeats 2 times. 13:53:25 147.743652 T:1528820768 NOTICE: Thread JobWorker start, auto delete: true 13:58:04 426.967926 T:1958097456 NOTICE: Previous line repeats 3 times. 13:58:04 426.968201 T:1958097456 ERROR: CPythonInvoker(9, /home/osmc/.kodi/addons/service.xbmc.callbacks-0.5/default.py): script didn't stop in 5 seconds - let's kill it 13:58:04 427.007233 T:1503654944 NOTICE: Thread JobWorker start, auto delete: true 13:58:04 427.144135 T:1545597984 NOTICE: Thread BackgroundLoader start, auto delete: false 13:58:07 429.420166 T:1545597984 NOTICE: Thread LanguageInvoker start, auto delete: false 13:58:07 429.609436 T:1528820768 NOTICE: Thread BackgroundLoader start, auto delete: false 13:58:07 429.690613 T:1681847328 WARNING: CPythonInvoker(9, /home/osmc/.kodi/addons/service.xbmc.callbacks-0.5/default.py): the python script "/home/osmc/.kodi/addons/service.xbmc.callbacks-0.5/default.py" has left several classes in memory that we couldn't clean up. The classes include: N14PythonBindings31XBMCAddon_xbmc_Monitor_DirectorE,N14PythonBindings30XBMCAddon_xbmc_Player_DirectorE 13:58:07 429.981659 T:1545597984 NOTICE: -->Python Interpreter Initialized<-- 13:58:10 432.544098 T:1681847328 NOTICE: Thread JobWorker start, auto delete: true 13:58:12 435.256744 T:1717335072 NOTICE: Previous line repeats 2 times. 13:58:12 435.257050 T:1717335072 NOTICE: Thread BackgroundLoader start, auto delete: false 13:58:15 437.688690 T:1717335072 NOTICE: Previous line repeats 1 times. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-10-04 (2015-10-04, 14:06)JANGER Wrote: I try to use it in RPi OSMC version. Please post a full log to pastebin.com or xbmclogs.com and post the link here. Moderators frown upon posting whole logs in the forum and I cannot tell anything looking at this fragment. Also, it looks like you are using the original script. I can provide more help and there is more debugging information if you install my fork: https://github.com/KenV99/service.xbmc.callbacks2 RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - JANGER - 2015-10-04 Never mind. I fixed! Thanks KenV99. I've written this message before server displayed your answer above. I found: (2015-06-22, 23:49)KenV99 Wrote: If you installed my version from GitHub there aren't any dependencies. This is displayed as version 2. And it works fantastic in RPi OSMC ! That's what I need! Dimming lights im my cinema automatically! I send ordinary TCP/IP GET parameters to wifi-enabled dimmer. Next step: can I use this add-on to play some video file before the movie start playing? I know there is Cinema Experience add-on. But I do'n want such many features. And it also has problems in RPi. So... sould I write some python script? and use it oposite to the above ordinary GET messsage. Inside such script: execute the selected video file, wait the end, send tcpip message, start playing the main movie. Is it possible? (2015-10-04, 14:06)JANGER Wrote: I try to use it in RPi OSMC version. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-10-04 (2015-10-04, 14:49)JANGER Wrote: This is displayed as version 2. You'll need to write a python script which subclasses xbmc.Player(): http://mirrors.kodi.tv/docs/python-docs/15.x-isengard/xbmc.html#Player Specifically you'll need to: 1) save the current playing file using Player.getPlayingFile() 2) call Player.stop() 3) call Player.start() using the url or whatever it is you want to play. Set a flag so that .onPlayBackStopped() knows to run when this finishes and not when you called stop in step 2. 4) write a routine for Player.onPlayBackStopped() to run the original file that you saved in step 1 only when the flag from step 3 is true If you really want user interaction to select a file to play before the main video file, then you'll need to write the UI code to display the menu as well. Although I've outlined the elemental steps you need above, I do not have the time to code this myself. Good luck! EDIT: You'll also need to write a main loop that doesn't exit until the onPlayBackStopped() code that restarts the original video file has executed. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - tekno - 2015-10-17 I have been using this on linux, and just tried it with a cleanup script on ATV2 as posted below however addon says "Command Not Valid" I can run the script from the command line. Unfortunately this is very needed on ATV2 due to its lack of ability to automate in other ways #!/bin/sh rm -f /home/kodi/kodi_crash*.log rm -f /home/kodi/.kodi/addons/packages/*.zip rm -f /home/kodi/.kodi/temp/*.idx rm -f /home/kodi/.kodi/temp/*.smi rm -f /home/kodi/.kodi/temp/*.ssa rm -f /home/kodi/.kodi/temp/*.ass rm -f /home/kodi/.kodi/temp/*.srt rm -f /home/kodi/.kodi/temp/*.sub rm -f /home/kodi/.kodi/temp/*.fi rm -f /home/kodi/.kodi/temp/*.mpl rm -f /home/kodi/.kodi/temp/*.cache rm -f /home/kodi/.kodi/temp/*.dat rm -f /home/kodi/.kodi/temp/*.zip rm -f /home/kodi/.kodi/temp/*.rar rm -f /home/kodi/.kodi/temp/*.mpg rm -f /home/kodi/.kodi/temp/*.avi rm -f /home/kodi/.kodi/temp/*.mp4 rm -f /home/kodi/.kodi/temp/*.mkv rm -f /home/kodi/.kodi/temp/*.3gp rm -f /home/kodi/.kodi/temp/*.ts rm -f /private/var/mobile/Library/Preferences/Kodi/addons/packages/*.zip rm -f /private/var/mobile/Library/Caches/AppleTV/Video/LocalAndRental/* rm -f /private/var/mobile/Library/Caches/AppleTV/Video/Other/* rm -f /private/var/cache/apt/archives/*.deb rm -f /private/var/cache/apt/archives/partial/* exit 0 also tried with #!bin/bash as first line and either runs when I ssh to atv2 and manually run the script. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - KenV99 - 2015-10-17 Since you didn't link to a log my assumption is that it is the log that says 'Command Not Valid' as opposed to there being an exception/error? I also assume that you have the above script in a file called script.sh or similar and the permissions/execute bit is properly set (i.e. you aren't root or su when you test it)? I also assume that you have checked off to run it as a shell command (requires shell)? I don't have any experience with ATV2 so beyond the above, I don't have any ideas. RE: [RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...) - schumi2004 - 2015-11-11 Would it be possible to have this script to react on certain addon actions only? For example only kick in when Retrospect stream stops playing instead of all (local and remote) media? Or on http or rtmp streams only? |