本文介绍了停止奇异的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想在点击事件时停止播放这部奇异的视频(默认播放).我在树莓派PI上运行它.这是我的kv和python代码.

I want to stop this kivy video on tap event(play by default). I'm running this on the raspberry PI. Here's my kv and python code.

<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

视频将循环播放,点击后会切换到新屏幕登录",但视频不会停止并且仍在循环播放(我想在加载新屏幕后停止播放).使用屏幕管理器还可以将许多其他屏幕屏幕连接到视频屏幕.假设加载屏幕工作正常.忽略缩进.

The video is played in loops and on tap it switches to new screen 'Login' but the video doesn't stops and is still playing in loops(I want to stop this after new screen is loaded). There are many other screen screens connected to video screen using screen manager. Assume that loading screens works fine. Ignore the indentation.

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更改时,视频的状态都将以相同的方式更改.您应该在(触摸)事件上更改此变量以暂停视频:

This part binds Video widget's state to property current_video_state: each time current_video_state changed, video's state would be changed same way. You should change this variable on (touch) event to pause video:

def on_stop(self,  *args):
    self.current_video_state = 'pause'  # this will change video state to 'pause'
    self.parent.current = 'Login'

这篇关于停止奇异的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:09