Stopping and starting a complex playlist - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111) +---- Forum: Raspberry Pi (https://forum.kodi.tv/forumdisplay.php?fid=166) +---- Thread: Stopping and starting a complex playlist (/showthread.php?tid=207049) |
Stopping and starting a complex playlist - 2santo2 - 2014-10-23 I have built an application that will play six hours of mixed media for an old peoples home. Included are videos; music with moving images backgrounds; and quiet times with no sound. The script for this is based upon some 20 playlists, example entries are: xbmc.executebuiltin("PlayMedia(/home/pi/.xbmc/userdata/playlists/video/Sect2_vid1.m3u)") time.sleep(437) xbmc.executebuiltin("PlayMedia(/home/pi/.xbmc/userdata/playlists/music/Sect2_mus1.m3u)") xbmc.executebuiltin("SlideShow(/media/TRANS_SD_B/Interlude,recursive,random)") time.sleep(353) To start the script I have a line in Home.xml <onclick>XBMC.RunScript(special://skin/scripts/leonie_script.py)</onclick> The difficulty is that there seems no easy way of stopping the script short of turning off the Raspberry Pi. Even if I turn off a video that is running, when the next xbmc.executebuiltin comes up, the next item starts running. The script is still running in the background. I have mapped the '0' button on my remote to 'StopScript', thinking I could have a 'while not StopScript' statement at the top of my leonie_script.py. This is aimed at putting leonie_script.py in a loop waiting for something to happen, while playing the content. I would very much appreciate assistance with suitable python code to stop the complex leonie_script.py script. I can't find anything after several hours of looking. The skin is Confluence. RE: Stopping and starting a complex playlist - Milhouse - 2014-10-23 A quick hack/fix would be for your "StopScript" to create a control file (eg. /tmp/stop.file) which you test the existence of before every step in your leonie_script.py - if the file exists, you exit. Eg: Code: def checkabort(): In your 'StopScript', simply create the file /tmp/stop.file, then stop the current player. I'm guessing that the various xbmc.executebuiltin() calls will block until they finish, in which case execution of the leonie_script.py only continues once the player is stopped, and the script should then exit if/when it detects the presence of the "stop.file". If the "StopScript" is executed while leonie_script.py is sleeping, leonie_script.py will exit as soon as it wakes up from sleep. You could of course implement a sleep that wakes every 1 second and checks for the abort, I've added that above too, so now leonie_script.py should execute more or less immediately after the StopScript is called. Edit: Or are the sleeps acting as the "blocks" until the preceding item has completed playing (ie. the first playlist Sect2_vid1.m3u has a duration of 437 seconds?) If so it shouldn't really matter, although you could simplify/streamline the workflow further: Code: def checkabort(): RE: Stopping and starting a complex playlist - 2santo2 - 2014-10-23 Thanks Milhouse, I'll get to work on the hack. RE: Stopping and starting a complex playlist - 2santo2 - 2014-11-05 The suggested coding has now been incorporated and works fine, I have tested it over many days. Thanks Milhouse. |