Posts: 8
Joined: Jan 2005
Reputation:
0
how do you write a script that does stuff immediately after xbmc.player() stops playing?
if i put commands after the xbmc.player()play command, they just run immediately, even while the player is still playing. can i make scripts pause while the player is playing, or do i have to somehow capture the state of the player, so i know when it has stopped? how would i do that?
thanks
john
Posts: 928
Joined: Feb 2004
Reputation:
0
Asteron
"Skilled" Python Coder
Posts: 928
you have to extend the player() class and define the onplaybackended method or something like that. its similar to how you extend the window and add an onaction() method. then you have to use that player instead of the xbmc.player.
check out the xbmc module doc (its in a sticky) for specifics.
Posts: 8
Joined: Jan 2005
Reputation:
0
thanks for the tip. i'll give it a try. i'm new to all this and so i don't know where to find the sticky you refer to. where is it?
john
Posts: 707
Joined: Jul 2004
Reputation:
6
i think the method onplaybackended() does not work.
maybe team can tell us what is true... (it should work but not for all video files)
maybe you can do this trick :
create a thread class, this one will launch the player and then loop on a time.sleep(1) and test : player.isplaying() or something like that. when player.isplaying is false, set a flag to tell your script it can go on ...
Posts: 707
Joined: Jul 2004
Reputation:
6
i think i remember that onplaybackended() works for some but not all media files...
Posts: 174
Joined: Mar 2004
Reputation:
0
madtw
Senior Member
Posts: 174
onplaybackended() is called when xbmc reaches the end of file and stops playing.
onplaybackstopped() is called when the user stops playback of a file.
with both of those functions, you should be able to execute code whenever a media file stops playing (if file playback was started from python).
Posts: 707
Joined: Jul 2004
Reputation:
6
is these theorical ? or practical ?
because , i don't know if it has been fixed, but these functions to find the end where not very functionnal for all file types....
Posts: 174
Joined: Mar 2004
Reputation:
0
madtw
Senior Member
Posts: 174
well, i've only been using those functions with video files... but i recently added the onplaybackstopped() method to xbmc and i didn't put file type specific code before calling the method in your python objects. i agree it might have looked like the functions did not always work when only onplaybackended() existed... that function is only called when xbmc finishes playing the *entire* file. that is why i added onplaybackstopped().