Kivy更改视频源

时间:2019-03-09 20:46:37

标签: python kivy

好吧,所以,如果我想在第一部电影和按钮之间添加另一部电影,我是否必须添加一个新屏幕或更改此功能中的视频源self.bind(on_touch_down = self.on_stop)?我想添加一个带有倒计时时间的视频,然后让他通过拍照释放相机。然后使用按钮将这张照片显示一次:重复并继续。

from kivy.app import App
from kivy.logger import Logger
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.video import Video
from kivy.uix.label import Label
from kivy.uix.button import Button



class Player(Video):
def __init__(self,  **kwargs):
    super(Player,  self).__init__(**kwargs)
    self.source = './START.mp4'
    self.state='play'
    self.options={'eos': 'loop'}
    self.bind(on_touch_down = self.on_stop)

def check(self):
    Logger.info("film position:" + str(self.position))

def on_stop(self,  *args):
    print ('I have been clicked')
    self.state='stop'  # stop the video
    sm.current = 'WindowApp'  # switch to the other Screen


class MyWindowApp(Screen):

def __init__(self, **kwargs):
    super(MyWindowApp, self).__init__(**kwargs)


    self.btn = Button(text='Push Me!', pos_hint={'center_x': 0.5, 'center_y': 0.75}, size_hint=(0.2, 0.2))
    self.lbl = Label(text='Read Me!', pos_hint={'center_x': 0.5, 'center_y': 0.25})

    self.add_widget(self.btn)
    self.add_widget(self.lbl)

sm = ScreenManager()
screen1 = Screen(name='video')
screen1.add_widget(Player())
sm.add_widget(screen1)
screen2 = MyWindowApp(name='WindowApp')
sm.add_widget(screen2)

class VideoPlayerApp(App):
def build(self):
    return sm


VideoPlayerApp().run()

0 个答案:

没有答案