bugfix
This commit is contained in:
parent
c0ce4b34e0
commit
528eeb511c
@ -50,10 +50,12 @@ class BaseVPlayer(FloatLayout):
|
|||||||
else:
|
else:
|
||||||
self.playlist = [vfile]
|
self.playlist = [vfile]
|
||||||
self.curplay = 0
|
self.curplay = 0
|
||||||
self.play()
|
|
||||||
self._video.bind(eos=self.video_end)
|
self._video.bind(eos=self.video_end)
|
||||||
self._video.bind(state=self.on_state)
|
self._video.bind(state=self.on_state)
|
||||||
set_log_callback(self.ffplayerLog)
|
set_log_callback(self.ffplayerLog)
|
||||||
|
self.play()
|
||||||
|
if hasattr(self._video._video, '_ffplayer'):
|
||||||
|
self.ffplayer = self._video._video._ffplayer
|
||||||
|
|
||||||
def on_source_error(self,o,v):
|
def on_source_error(self,o,v):
|
||||||
Logger.info('safecorner: {} error'.format(v))
|
Logger.info('safecorner: {} error'.format(v))
|
||||||
@ -65,14 +67,6 @@ class BaseVPlayer(FloatLayout):
|
|||||||
if level == 'error' and self._video.source in msg:
|
if level == 'error' and self._video.source in msg:
|
||||||
self.dispatch('on_source_error',self,self._video.source)
|
self.dispatch('on_source_error',self,self._video.source)
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self._video is None:
|
|
||||||
return
|
|
||||||
self._video.state = 'pause'
|
|
||||||
Window.allow_screensaver = True
|
|
||||||
del self._video
|
|
||||||
self._video = None
|
|
||||||
|
|
||||||
def play(self,o=None,v=None):
|
def play(self,o=None,v=None):
|
||||||
if self.curplay >= 0:
|
if self.curplay >= 0:
|
||||||
self._video.source = self.playlist[self.curplay]
|
self._video.source = self.playlist[self.curplay]
|
||||||
@ -85,12 +79,7 @@ class BaseVPlayer(FloatLayout):
|
|||||||
self.playlist += lst
|
self.playlist += lst
|
||||||
|
|
||||||
def video_end(self,t,v):
|
def video_end(self,t,v):
|
||||||
self._video.unload()
|
pass
|
||||||
return
|
|
||||||
self.curplay += 1
|
|
||||||
self.curplay = self.curplay % len(self.playlist)
|
|
||||||
self._video.source = self.playlist[self.curplay]
|
|
||||||
self._video.state = 'play'
|
|
||||||
|
|
||||||
def on_state(self,o,v):
|
def on_state(self,o,v):
|
||||||
if self._video.state == 'play':
|
if self._video.state == 'play':
|
||||||
@ -182,10 +171,7 @@ class BaseVPlayer(FloatLayout):
|
|||||||
self._video.volume = self.old_volume
|
self._video.volume = self.old_volume
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
try:
|
|
||||||
self._video.state = 'stop'
|
self._video.state = 'stop'
|
||||||
except:
|
|
||||||
print_exc()
|
|
||||||
|
|
||||||
def pause(self,t=None):
|
def pause(self,t=None):
|
||||||
if self._video.state == 'play':
|
if self._video.state == 'play':
|
||||||
@ -193,6 +179,9 @@ class BaseVPlayer(FloatLayout):
|
|||||||
else:
|
else:
|
||||||
self._video.state = 'play'
|
self._video.state = 'play'
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class OSCVPlayer(BaseVPlayer):
|
class OSCVPlayer(BaseVPlayer):
|
||||||
def __init__(self,ip,port,vfile=None):
|
def __init__(self,ip,port,vfile=None):
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
@ -247,28 +236,15 @@ class VPlayer(BaseVPlayer):
|
|||||||
self._video.bind(on_touch_down=self.show_hide_menu)
|
self._video.bind(on_touch_down=self.show_hide_menu)
|
||||||
self.register_event_type('on_playend')
|
self.register_event_type('on_playend')
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
print('********** delete VPlayer instance ********')
|
|
||||||
if self._video is None:
|
|
||||||
return
|
|
||||||
if self.update_task:
|
|
||||||
self.update_task.cancel()
|
|
||||||
self.update_task = None
|
|
||||||
self._video.state = 'pause'
|
|
||||||
Window.allow_screensaver = True
|
|
||||||
del self._video
|
|
||||||
self._video = None
|
|
||||||
|
|
||||||
|
|
||||||
def video_end(self,t,v):
|
def video_end(self,t,v):
|
||||||
super().video_end(t,v)
|
|
||||||
self.curplay += 1
|
self.curplay += 1
|
||||||
if not self.loop and self.curplay >= len(self.playlist):
|
if not self.loop and self.curplay >= len(self.playlist):
|
||||||
self.dispatch('on_playend')
|
self.dispatch('on_playend')
|
||||||
|
print('*****EOS return *************')
|
||||||
|
self.beforeDestroy()
|
||||||
return
|
return
|
||||||
self.curplay = self.curplay % len(self.playlist)
|
self.curplay = self.curplay % len(self.playlist)
|
||||||
self._video.source = self.playlist[self.curplay]
|
self._video.source = self.playlist[self.curplay]
|
||||||
self._video.state = 'play'
|
|
||||||
|
|
||||||
def totime(self,dur):
|
def totime(self,dur):
|
||||||
h = dur / 3600
|
h = dur / 3600
|
||||||
@ -277,9 +253,6 @@ class VPlayer(BaseVPlayer):
|
|||||||
return '%02d:%02d:%02d' % (h,m,s)
|
return '%02d:%02d:%02d' % (h,m,s)
|
||||||
|
|
||||||
def createProgressBar(self):
|
def createProgressBar(self):
|
||||||
if hasattr(self._video._video, '_ffplayer'):
|
|
||||||
self.ffplayer = self._video._video._ffplayer
|
|
||||||
|
|
||||||
if self.pb is None:
|
if self.pb is None:
|
||||||
self.pb = BoxLayout(orientation='horizontal',
|
self.pb = BoxLayout(orientation='horizontal',
|
||||||
size_hint = (0.99,None),height=CSize(1.4))
|
size_hint = (0.99,None),height=CSize(1.4))
|
||||||
@ -302,7 +275,6 @@ class VPlayer(BaseVPlayer):
|
|||||||
self.pb.add_widget(self.slider)
|
self.pb.add_widget(self.slider)
|
||||||
self.pb.add_widget(self.maxposition)
|
self.pb.add_widget(self.maxposition)
|
||||||
self.menubar.add_widget(self.pb)
|
self.menubar.add_widget(self.pb)
|
||||||
self.update_task = Clock.schedule_interval(self.update_slider,1)
|
|
||||||
|
|
||||||
def enterManualMode(self,obj,touch):
|
def enterManualMode(self,obj,touch):
|
||||||
if not self.slider.collide_point(*touch.pos):
|
if not self.slider.collide_point(*touch.pos):
|
||||||
@ -318,18 +290,20 @@ class VPlayer(BaseVPlayer):
|
|||||||
self.manualMode = False
|
self.manualMode = False
|
||||||
|
|
||||||
def update_slider(self,t):
|
def update_slider(self,t):
|
||||||
|
if self.pb is None:
|
||||||
|
return
|
||||||
self.curposition.text = self.totime(self._video.position)
|
self.curposition.text = self.totime(self._video.position)
|
||||||
if not self.manualMode:
|
if not self.manualMode:
|
||||||
self.slider.value = self._video.position
|
self.slider.value = self._video.position
|
||||||
self.slider.max = self._video.duration
|
self.slider.max = self._video.duration
|
||||||
self.maxposition.text = self.totime(self._video.duration)
|
self.maxposition.text = self.totime(self._video.duration)
|
||||||
|
|
||||||
def beforeDestroy(self):
|
def __del__(self):
|
||||||
try:
|
self.beforeDestroy()
|
||||||
del self
|
|
||||||
|
|
||||||
except Exception as e:
|
def beforeDestroy(self):
|
||||||
print_exc()
|
print('beforeDestroy() called')
|
||||||
|
self._video.state = 'stop'
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def show_hide_menu(self,obj,touch):
|
def show_hide_menu(self,obj,touch):
|
||||||
@ -424,6 +398,15 @@ class VPlayer(BaseVPlayer):
|
|||||||
else:
|
else:
|
||||||
self.btn_pause.source = blockImage('pause.jpg')
|
self.btn_pause.source = blockImage('pause.jpg')
|
||||||
|
|
||||||
|
def on_state(self,o,v):
|
||||||
|
BaseVPlayer.on_state(self,o,v)
|
||||||
|
if self._video.state == 'play':
|
||||||
|
self.update_task = Clock.schedule_interval(self.update_slider,1)
|
||||||
|
else:
|
||||||
|
if self.update_task:
|
||||||
|
self.update_task.cancel()
|
||||||
|
self.update_task = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
class MyApp(App):
|
class MyApp(App):
|
||||||
def build(self):
|
def build(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user