停止kivy视频
问题描述:
我想停止点击事件中的此kivy视频(默认播放)。我在树莓派上运行它。这是我的kv和python代码。停止kivy视频
<VideoScreen>:
name: 'Video'
BoxLayout:
Video:
id: 'video1'
source: './media/Sequence_#1.mp4'
state: root.current_video_state
volume: 1
options: {'eos': 'loop'}
allow_stretch: True
的视频在循环播放并且自来水切换到新的屏幕“登录”但视频没有停止做,并且仍然在循环播放(我想新的画面加载后停止此)。使用屏幕管理器连接到视频屏幕还有许多其他屏幕屏幕。假设加载屏幕正常工作。忽略缩进。
class VideoScreen(Screen):
current_video_state = StringProperty()
def __init__(self, **kwargs):
super(VideoScreen, self).__init__(**kwargs)
self.bind(on_touch_down = self.on_stop)
self.current_video_state = self.get_set_current_video_state()
def get_set_current_video_state(self, *args):
while(args):
print('arg', args[0])
if args[0] == 'pause':
return 'pause'
return 'play'
def on_stop(self, *args):
self.state = 'pause'
self.get_set_current_video_state('pause')
self.parent.current = 'Login'
答
Video:
# ...
state: root.current_video_state
这部分结合视频控件的状态属性current_video_state
:每个current_video_state
变化时,视频的状态将被改变一样。您应该在(触摸)事件中更改此变量以暂停视频:
def on_stop(self, *args):
self.current_video_state = 'pause' # this will change video state to 'pause'
self.parent.current = 'Login'
视频小工具在树莓派上适合您吗?我无法让它工作,我认为很多其他人也有同样的问题。我们使用了一种解决方法,如https://gist.github.com/natcl/005dc4c6434ed7b5a59a。你有没有做任何特定的事情使它在树莓派上工作? – PalimPalim