bugfix
This commit is contained in:
parent
47e554faeb
commit
edac4f5c1d
@ -40,9 +40,11 @@ othersplatforms=['ios','android']
|
|||||||
|
|
||||||
class BaseVPlayer(FloatLayout, SwipeBehavior):
|
class BaseVPlayer(FloatLayout, SwipeBehavior):
|
||||||
fullscreen = BooleanProperty(False)
|
fullscreen = BooleanProperty(False)
|
||||||
def __init__(self,vfile=None,playlist=[]):
|
def __init__(self,vfile=None,loop=None,mute=False):
|
||||||
FloatLayout.__init__(self)
|
FloatLayout.__init__(self)
|
||||||
SwipeBehavior.__init__(self)
|
SwipeBehavior.__init__(self)
|
||||||
|
self.loop = loop
|
||||||
|
self.muteFlg = mute
|
||||||
self.register_event_type('on_source_error')
|
self.register_event_type('on_source_error')
|
||||||
self.register_event_type('on_next')
|
self.register_event_type('on_next')
|
||||||
self.register_event_type('on_previous')
|
self.register_event_type('on_previous')
|
||||||
@ -50,36 +52,40 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
|
|||||||
self._video = Video(allow_stretch=True)
|
self._video = Video(allow_stretch=True)
|
||||||
self.add_widget(self._video)
|
self.add_widget(self._video)
|
||||||
self.nextdir = None
|
self.nextdir = None
|
||||||
if type(vfile) == type([]):
|
self.playlist = []
|
||||||
self.playlist = vfile
|
|
||||||
else:
|
|
||||||
self.playlist = [vfile]
|
|
||||||
self.curplay = 0
|
self.curplay = 0
|
||||||
self.old_volume = 0
|
self.old_volume = 0
|
||||||
self._video.bind(state=self.on_state)
|
self._video.bind(state=self.on_state)
|
||||||
|
# self._video.bind(loaded=self.playVideo) no effect
|
||||||
self._video.bind(position=self.positionChanged)
|
self._video.bind(position=self.positionChanged)
|
||||||
|
if loop:
|
||||||
|
self.eos = 'loop'
|
||||||
|
|
||||||
self.bind(on_swipe_down=self.previous)
|
self.bind(on_swipe_down=self.previous)
|
||||||
self.bind(on_swipe_up=self.next)
|
self.bind(on_swipe_up=self.next)
|
||||||
set_log_callback(self.ffplayerLog)
|
set_log_callback(self.ffplayerLog)
|
||||||
self.play()
|
|
||||||
if hasattr(self._video._video, '_ffplayer'):
|
if hasattr(self._video._video, '_ffplayer'):
|
||||||
self.ffplayer = self._video._video._ffplayer
|
self.ffplayer = self._video._video._ffplayer
|
||||||
|
if vfile is not None:
|
||||||
|
self.setSource(vfile)
|
||||||
|
|
||||||
def positionChanged(self,o,v):
|
def positionChanged(self,o,v):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def playVideo(self,o=None,v=None):
|
||||||
|
# print('-------------VPlayer():playVideo()')
|
||||||
|
self._video.state = 'play'
|
||||||
|
self.nextdir = None
|
||||||
|
if self.muteFlg:
|
||||||
|
self.setVolume(None,0)
|
||||||
|
|
||||||
def setSource(self,s):
|
def setSource(self,s):
|
||||||
self.stop()
|
self.stop()
|
||||||
self.curplay = 0
|
self.curplay = 0
|
||||||
self.playlist = [s]
|
self.playlist = [s]
|
||||||
|
self._video.source = self.playlist[self.curplay]
|
||||||
Logger.info('kivyblocks: Vplayer().setSource,s=%s',s)
|
Logger.info('kivyblocks: Vplayer().setSource,s=%s',s)
|
||||||
self.play()
|
self.playVideo()
|
||||||
|
|
||||||
def setPlaylist(self,pl):
|
|
||||||
self.stop()
|
|
||||||
self.curplay = 0
|
|
||||||
self.playlist = pl
|
|
||||||
self.play()
|
|
||||||
|
|
||||||
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))
|
||||||
@ -117,6 +123,8 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
|
|||||||
def on_state(self,o=None,v=None):
|
def on_state(self,o=None,v=None):
|
||||||
if self._video.state == 'play':
|
if self._video.state == 'play':
|
||||||
Window.allow_screensaver = False
|
Window.allow_screensaver = False
|
||||||
|
if self.muteFlg:
|
||||||
|
self.setVolume(None,0)
|
||||||
else:
|
else:
|
||||||
Window.allow_screensaver = True
|
Window.allow_screensaver = True
|
||||||
if self._video.state == 'stop':
|
if self._video.state == 'stop':
|
||||||
@ -242,25 +250,17 @@ class OSCController:
|
|||||||
self.dispatcher.map(p,f,None)
|
self.dispatcher.map(p,f,None)
|
||||||
|
|
||||||
class VPlayer(BaseVPlayer):
|
class VPlayer(BaseVPlayer):
|
||||||
def __init__(self,vfile=None, loop=False):
|
def __init__(self,vfile=None, loop=False,mute=False, opbar=True):
|
||||||
super().__init__(vfile=vfile)
|
super().__init__(vfile=vfile,loop=loop,mute=mute)
|
||||||
self.loop = loop
|
self.opbar = opbar
|
||||||
self.menubar = None
|
self.menubar = None
|
||||||
self._popup = None
|
self._popup = None
|
||||||
self.menu_status = False
|
self.menu_status = False
|
||||||
self.manualMode = False
|
self.manualMode = False
|
||||||
self.pb = None
|
self.pb = None
|
||||||
if vfile:
|
|
||||||
if type(vfile) == type([]):
|
|
||||||
self.playlist = vfile
|
|
||||||
else:
|
|
||||||
self.playlist = [vfile]
|
|
||||||
self.curplay = 0
|
|
||||||
self.play()
|
|
||||||
else:
|
|
||||||
self.playlist = []
|
|
||||||
self.curplay = -1
|
|
||||||
self._video.bind(on_touch_down=self.show_hide_menu)
|
self._video.bind(on_touch_down=self.show_hide_menu)
|
||||||
|
if self.loop:
|
||||||
|
self.eos = 'loop'
|
||||||
|
|
||||||
def totime(self,dur):
|
def totime(self,dur):
|
||||||
h = dur / 3600
|
h = dur / 3600
|
||||||
@ -340,6 +340,9 @@ class VPlayer(BaseVPlayer):
|
|||||||
print('doube_tap')
|
print('doube_tap')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.opbar:
|
||||||
|
return
|
||||||
|
|
||||||
if not self.menubar:
|
if not self.menubar:
|
||||||
self.buildMenu()
|
self.buildMenu()
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user