Solved Grabbing the Player.Stop event from python
#1
For one addon that I'm developing I need to grab the user request to stop the playback. I don't want to execute code onPlayBackStopped() but to literally know from python (or a service) the user has asked kodi to stop the playback. The reason I'm doing this is because I need to force close an external closed source application that is serving video to kodi (otherwise kodi will eventually crash).

Any suggestions?
Reply
#2
(2015-08-12, 18:20)enen92 Wrote: For one addon that I'm developing I need to grab the user request to stop the playback. I don't want to execute code onPlayBackStopped() but to literally know from python (or a service) the user has asked kodi to stop the playback. The reason I'm doing this is because I need to force close an external closed source application that is serving video to kodi (otherwise kodi will eventually crash).

Any suggestions?

Why can't you use onPlayBackStopped? not following Smile

You can use onaction to catch the stop button when it's pressed... but take in mind this will also trigger onPlayBackStopped

ACTION_STOP = 13
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
Onplaybackstoped will only be called if the playback is stopped. Problem is, Kodi freezes and the playback is not stopped. Hence, the code I want to run is never triggered.

To use on action I need to have a custom window right?
Reply
#4
(2015-08-13, 02:06)enen92 Wrote: Onplaybackstoped will only be called if the playback is stopped. Problem is, Kodi freezes and the playback is not stopped. Hence, the code I want to run is never triggered.

To use on action I need to have a custom window right?

Yeah... you need a custom window... Not sure what type of plugin you are creating...so it might not work out for you.

I know its sloppy but maybe capture kodi log printouts? otherwise there aren't many alternatives I can think of for monitoring stop status.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#5
Does anyone have a code snippet as an example?

I would need to capture the "on start" action, the onplaybackstarted event handler is to late for me. I need to know when the user would like to start playing a video, not when it is already playing...

Thanks!
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply
#6
I ended up starting a thread onPlaybackStarted to check (using the json-rpc api) for Player.GetActivePlayers. I found out that as soon as you hit stop, even though kodi freezes, the list of active players is null. So, I do my stuff as soon as the list of active players is empty and kodi won't freeze anymore.
I also looked into xbmc.getCondVisibility('Player.Playing') but it tends to report False when the stream is buffering, dropping the playback.


Wimpie, you probably want to do "your stuff" on player __init__ and not playbackstarted.

Thanks Lunatixz
Reply
#7
(2015-08-15, 22:19)enen92 Wrote: Wimpie, you probably want to do "your stuff" on player __init__ and not playbackstarted.

I'll try that. Thanks for the tip!
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply

Logout Mark Read Team Forum Stats Members Help
Grabbing the Player.Stop event from python0