Kodi Community Forum

Full Version: sequential 'onclick' events
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It it possible to have sequential onclick events such as:
<onclick>PlayMedia(address of a movie say),Playmedia(address of a music album say),...</onclick>
I tried just stacking them as a series of onclicks but it jumps from one to the other really quickly and does the last one
The reason I want to do this is that I want to be able to play the weather video then jump back to an m3u
we can not write <onclick> in that way (as far as I know)

But we can write multiple <onclick> for any button and commands inside those will be executed simultaneously.

So unfortunately you will listen only last song
I tried that:
<Onclick>action1</onclick>
<Onclick>action2</onclick>
and action1 was a video. The second action does not run.
The actual script is:
<onclick>PlayMedia($INFO[Window.Property(Video.1)],noresume)</onclick>
<onclick>xbmc.executebuiltin( "PlayMedia(C:\Users\name\AppData\Roaming\XBMC\userdata\playlists\music\playlist.m3u)" )</onclick>
You can't play a video and music at the same time. You will need a script which monitors the start/stop actions from the player. Exact resume will still not be possible but you can restart the m3u after playing a video.
I agree, I don't want to play them together but I thought maybe it would just do one then the next, clearly a stuff up.. What you have said is exactly what I want to do, - restart the m3u after the video. so can you help me with that? I mean it would appear to be a simple exercise by creating a playlist.m3u, placing the items in a folder maybe and putting their addresses in the m3u. The problem is that the video is the ABC Weather video that is downloaded as required so it cant have a simple local address
How do I write a script to monitor the start/stop actions of the player?
Ok, I have this script and it works. It starts up my m3u. I tested it by creating a temporary button and used <onclick>.....</onclick>

RunScript(C:\Users\Pan2\AppData\Roaming\XBMC\userdata\autoexec.py

Where do I put it so that it is executed when the Player has stopped?
I don't think, you can execute an script when the Player has stopped.
There should be something to monitor if Player has stopped, so your script needs to run all the time and your script should keep checking after some interval whether the Player has stopped.

You can start your script on skin load by putting your script in "Startup.xml" like this:

<onload>RunScript(special://skin/720p/autoexec.py)</onload>

That assumes the script is in the skin's 720p directory but it can be somewhere else also.
Try this -> script.audioresume-0.0.1.zip. Script does the following:

If music is playing the script saves the current playlist to variable and constantly saves the current position and seek time. If you play a video in between, the script will continue playing the playlist at the exact position and time after you stop the video (or it stops itself = playback ended).

Add this to Startup.xml:
<onload>RunScript(script.audioresume)</onload>
Thanks mate, there are a few other bits and pieces in that zip file.
I assume there is more to it than just adding that line to the Startup.xml, I'm just not sure what to do with the other bits or if in fact they need to be edited in some way Tongue
I've updated the link... download again, go to the add-ons browser, select "Install from zip file", choose the zip and you're done. After adding the line to Startup.xml and restarting the skin it should work.
I actually got it to work without the update Smile apart from the MacOS stuff which I also removed, there is a typo in the addon.xml (a left over "</language>"). Once that is removed, rezipped and installed though settings --addons--install from zip file, it works. Just had to add the line in the startup.xml.
I take it that the python script is the heart of the mod. Noted the two sleep variables, and assume that if they were increased or decreased then the 'resume after video' can be delayed/shortened slightly.
Just wondering if there is python language for 'fade in/fade out' for volume because I think it would be really cool if the return to background music was gradual.
The OS X stuff (DS_Store) is the problem why it won't install, that's why I re-uploaded it. Fade in/out should be possible, just mute the volume and then increase in a loop with short sleeps between the steps.

You can adjust the resume delay but a short delay has to be there... if you remove the xbmc.sleep(2000) completely, it won't work. But increasing it is no problem.
Thanks very much for your help in this. I won't ask exactly how to create the fadein/out; I'll work that out myself Smile
Something I find curious is that there have been threads looking at background music and a number of contributions wanting the resume feature. Yet there had never been a mention of it that I saw until yours. I know now why you have the title a skilled skinner Smile