我正在使用Kivy视频组件在屏幕上播放公司视频,当我第二次停止播放它时,会导致应用程序挂断。
经过调试以尝试解决问题后,我发现它们挂在video_gstplayer.py中:
def seek(self, percent, precise=True):
self.player.seek(percent)
恰好在第二句话上;而前一个来自video.py:
def on_state(self, instance, value):
if not self._video:
return
if value == 'play':
if self.eos:
self._video.stop()
self._video.position = 0.
self._video.eos = False
self.eos = False
self._video.play()
elif value == 'pause':
self._video.pause()
else:
self._video.stop()
self._video.position = 0
self._video.eos = False
并完全跳到最后一个self._video.position = 0
。
我使用视频和窗口小部件的代码如下:
class Presentation(Screen):
def v_player(self):
if App.get_running_app().play == 0:
App.get_running_app().play = 1
App.get_running_app().video = Video(source='data/video/video.mp4')
App.get_running_app().video.state = 'play'
App.get_running_app().video.allow_stretch = True
self.add_widget(App.get_running_app().video)
else:
App.get_running_app().play = 1
def go_inicio(self):
if App.get_running_app().play == 1:
App.get_running_app().play = 0
App.get_running_app().video.state = 'stop'
self.remove_widget(App.get_running_app().video)
sm.current = 'inicio'
else:
App.get_running_app().play = 0
sm.current = 'inicio'
pass
我通过单击调用函数go_inicio
的“后退”按钮来停止视频。
App类的实现:
class GlomarkHome(App):
slide_pro = 0
slide_lit = 0
play = 0
video = 0
def build(self):
sm.add_widget(Inicio(name='inicio'))
sm.add_widget(Categoria(name='categoria'))
sm.add_widget(Presentation(name='presentation'))
sm.add_widget(Productos(name='productos'))
sm.add_widget(Obras(name='obras'))
sm.add_widget(Pgrid(name='pgrid'))
sm.add_widget(Pgrid_obras(name='pgrid_obras'))
sm.add_widget(Product_1(name='product_1'))
sm.add_widget(Product_2(name='product_2'))
return sm
pass
有什么主意吗?
预先感谢