Posts: 240
Joined: Mar 2014
Reputation:
6
Hi,
I'm having trouble detecting the start and end of video playback and i've no idea what the issue is. I've tried a lot of different setups with gotham such as:
import xbmc
import sys;
class SuperPlayer(xbmc.Player):
def __init__(self, *args, **kwargs):
pass
def onPlayBackStarted(self):
sys.stdout.write("playback started \n");
def onPlayBackEnded(self):
sys.stdout.write("playback ended \n");
def onPlaybackStopped(self):
sys.stdout.write("playback stopped \n");
however none of them seem to hit the functions
Posts: 1,088
Joined: Nov 2012
Reputation:
51
2014-07-01, 00:30
(This post was last modified: 2014-07-01, 00:31 by Karnagious.)
Are you instantiating the SuperPlayer?
Python doesnt use semi-colons at the end of the line.
Posts: 240
Joined: Mar 2014
Reputation:
6
Yes in the classes that play files we have e.g.
myPlayer = SuperPlayer();
myplayer.play(file);
which works fine, I can override the play() function and the breakpoints for that get hit. It just never ever hits the onPlayback statements and it's driving me mental.
I know python doesn't require semicolons but it's good practice to always terminate your lines =)
Posts: 1,088
Joined: Nov 2012
Reputation:
51
Your code above has no formatting, so I cant see the whitespace. But if the onPlayBackStarted method is accidentally outside the Class (not indented properly) then that would explain why it never gets hit.
Having a link to the full code would be helpful.
Posts: 240
Joined: Mar 2014
Reputation:
6
The threads are created using e.g.
thread = Thread(target = self.startTimer);
thread.start();
def startTimer(self):
time.sleep(self.updateInterval);
The main script ends after it's opened all it's threads and the created one's continue fine and do things like open video files etc in xbmc fine. It however doesn't do for example the onPlayBackStarted() call in the custom player but I have no idea why.
Posts: 507
Joined: Nov 2013
Reputation:
28
Well, again, with fragments, I can't be of much help, however, it's common practice in service modules to do what you have done - call xbmc.sleep(). Sleeping more than 5 seconds in your main thread will likely generate a message in the log that your script didn't exit but that is more of an annoyance to others who have to look at lots of logs than a real problem. Unless you are checking for xbmc.abortrequested in your threads and terminating them and exiting from there.
Posts: 236
Joined: Feb 2013
Reputation:
1
Check the AutoSubs addon, it detects when a video starts to call the subtitles service. So with some changes also can detect when the video stops.
Posts: 507
Joined: Nov 2013
Reputation:
28
You could also just call mythread.join() after mythread.start() to hold up there as well...