Kivy and Python How to Play Videos at two Videoplayer at the same video Position to another

Viewed 330

Kivy and Python: How to Play to videos at two videoplayer at the same position to another

The image below ilustres what i am making now What i am trying to do

Hello Everyone, I am serious apreciated for your help.

I am making a smart glasses with my android phone, and some things that i build. But i need that the same videos has the same position of playback, and plays at the same time and the same image appears at the two widgets.

The code of my attempt work :

import kivy
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label 
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.video import Video
from sys import argv
from os.path import dirname, join
from kivy.uix.videoplayer import VideoPlayer
from kivy.core.window import Window
kivy.require('2.0.0')
class smartGlasses(App):
    def on_touch_down(self, touch):
        if self.collide_point(*touch.pos):
            self.video_r.state = 'play'
            self.video_r.position = self.video_l.position
            return True
    def on_position_change(self, instance, value):
        self.video_r.position =  value
        #self.video_r.seek(value/100, precise=True)
    def on_duration_change(self, instance, value):
        self.video_r.duration =  value  
        #self.video_r.seek(value/100, precise=True)
    def build(self):    
        Window.size = (480,320)
        bl = BoxLayout(orientation="vertical")
        bl_left = BoxLayout(orientation="vertical")
        bl_right = BoxLayout(orientation="vertical")
        bc = BoxLayout(orientation="horizontal")    
        bh = BoxLayout(orientation="horizontal")
        btn_h = Button(text="Botton")   
        btn_t = Button(text="Upper")    
        bt = BoxLayout(orientation="horizontal")    
        btn = Button(text='center')
        if len(argv) > 1:
            filename = argv[1]
        else:
            curdir = dirname(__file__)
            filename = join(curdir, 'myVideo.mp4')
        self.video_l =  VideoPlayer(source=filename, state='play')
        self.video_r =  VideoPlayer(source=filename, state='play')
        self.video_l.bind(position=self.on_position_change,
               duration=self.on_duration_change)
        bl_left.add_widget(widget=self.video_l)
        bl_right.add_widget(widget=self.video_r)
        bc.add_widget(widget=bl_left)
        bc.add_widget(widget=btn)
        bc.add_widget(widget=bl_right)
        bh.add_widget(widget=btn_h)
        bt.add_widget(widget=btn_t)
        bl.add_widget(widget=bt)
        bl.add_widget(widget=bc)
        bl.add_widget(widget=bh)
        return bl
smartGlasses().run()

What happens? Now, When i try for to seek the video at the position to another video the timeline update the same current time to both videos, after the clickdown at the timeline to refresh the video position the video image not updtate at the second layout video player widget.

What happened with my smart glasses app

0 Answers
Related