Exemple #1
0
    def build(self):
        filename = 'videoplayback.avi'
        self.layout = GridLayout(cols=2)
        self.video = VideoPlayer(source=filename, state='play')
        self.layout.add_widget(self.video)

        button1 = Button(text='Play video1', font_size=14)
        button1.bind(on_press=self.play_video1)
        button1.size_hint = (0.2, 0.1)
        self.layout.add_widget(button1)
        button2 = Button(text='pauza video1', font_size=14)
        button2.size_hint = (0.2, 0.1)
        button2.bind(on_press=self.pauza_video1)
        self.layout.add_widget(button2)
        button3 = Button(text='stop video1', font_size=14)
        button3.size_hint = (0.2, 0.1)
        button3.bind(on_press=self.stop_video1)
        self.layout.add_widget(button3)
        button4 = Button(text='la 1/3 din film', font_size=14)
        button4.size_hint = (0.2, 0.1)
        button4.bind(on_press=self.un_sfert_video1)
        self.layout.add_widget(button4)
        button5 = Button(text='la 2/3 din film', font_size=14)
        button5.size_hint = (0.2, 0.1)
        button5.bind(on_press=self.doua_sferturi_video1)
        self.layout.add_widget(button5)
        button6 = Button(text='volum : -', font_size=14)
        button6.size_hint = (0.2, 0.1)
        button6.bind(on_press=self.minus_video1)
        self.layout.add_widget(button6)
        button7 = Button(text='volum : +', font_size=14)
        button7.size_hint = (0.2, 0.1)
        button7.bind(on_press=self.plus_video1)
        self.layout.add_widget(button7)
        return self.layout
Exemple #2
0
    def on_enter(self):
        self.listim = self.manager.list1
        # self.grid = self.manager.gridtest
        x = self.manager.x

        print(self.listim)

        boxbot = Boxheight()
        boxbot.height = 45

        btnback = Button(text='Retour')
        btnback.bind(on_press=lambda a: self.disconnect())

        btnplay = Button(text='Lecture')
        btnpause = Button(text='Pause')
        btnstop = Button(text='Stop')

        btnsend = Button(text='Enregistrer')
        # btnsend.bind(on_press = lambda a: self.send())

        if x <= 2:
            gridscreen = GridLayout(cols=x)
            for y in self.listim:

                # newimage= y+'.avi'
                video = VideoPlayer(source=y + '.avi')
                video.state = 'pause'
                btnplay.bind(
                    on_press=lambda a, video=video: self.playvideo(video))
                btnpause.bind(
                    on_press=lambda a, video=video: self.pausevideo(video))
                btnstop.bind(
                    on_press=lambda a, video=video: self.stopvideo(video))

                gridscreen.add_widget(video)
        else:
            gridscreen = GridLayout(rows=x - 2)
            for y in self.listim:

                # newimage= y+'.avi'
                video = VideoPlayer(source=y + '.avi', state='pause')
                btnplay.bind(
                    on_press=lambda a, video=video: self.playvideo(video))
                btnpause.bind(
                    on_press=lambda a, video=video: self.pausevideo(video))
                btnstop.bind(
                    on_press=lambda a, video=video: self.stopvideo(video))
                gridscreen.add_widget(video)

        lastscreen = self.manager.get_screen('interface4').lastscreen
        lastscreen.clear_widgets()

        boxbot.add_widget(btnback)
        boxbot.add_widget(btnplay)
        boxbot.add_widget(btnpause)
        boxbot.add_widget(btnstop)
        boxbot.add_widget(btnsend)

        lastscreen.add_widget(gridscreen)
        lastscreen.add_widget(boxbot)
Exemple #3
0
class VideoPlayerApp(App):
    def build(self):
        filename = 'videoplayback.avi'
        self.layout = GridLayout(cols=2)
        self.video = VideoPlayer(source=filename, state='play')
        self.layout.add_widget(self.video)

        button1 = Button(text='Play video1', font_size=14)
        button1.bind(on_press=self.play_video1)
        button1.size_hint = (0.2, 0.1)
        self.layout.add_widget(button1)
        button2 = Button(text='pauza video1', font_size=14)
        button2.size_hint = (0.2, 0.1)
        button2.bind(on_press=self.pauza_video1)
        self.layout.add_widget(button2)
        button3 = Button(text='stop video1', font_size=14)
        button3.size_hint = (0.2, 0.1)
        button3.bind(on_press=self.stop_video1)
        self.layout.add_widget(button3)
        button4 = Button(text='la 1/3 din film', font_size=14)
        button4.size_hint = (0.2, 0.1)
        button4.bind(on_press=self.un_sfert_video1)
        self.layout.add_widget(button4)
        button5 = Button(text='la 2/3 din film', font_size=14)
        button5.size_hint = (0.2, 0.1)
        button5.bind(on_press=self.doua_sferturi_video1)
        self.layout.add_widget(button5)
        button6 = Button(text='volum : -', font_size=14)
        button6.size_hint = (0.2, 0.1)
        button6.bind(on_press=self.minus_video1)
        self.layout.add_widget(button6)
        button7 = Button(text='volum : +', font_size=14)
        button7.size_hint = (0.2, 0.1)
        button7.bind(on_press=self.plus_video1)
        self.layout.add_widget(button7)
        return self.layout

    def play_video1(self, buton):
        self.video.state = 'play'

    def pauza_video1(self, buton):
        self.video.state = 'pause'

    def stop_video1(self, buton):
        self.video.state = 'stop'

    def un_sfert_video1(self, buton):
        self.video.seek(0.33)

    def doua_sferturi_video1(self, buton):
        self.video.seek(0.66)

    def minus_video1(self, buton):
        if (self.video.volume > 0):
            self.video.volume -= 0.1

    def plus_video1(self, buton):
        if (self.video.volume < 1):
            self.video.volume += 0.1
Exemple #4
0
    def __init__(self, **kw):
        super().__init__(**kw)
        Window.size = (GetSystemMetrics(0), GetSystemMetrics(1))
        img = Image(source=os.path.join('assets', 'images', 'rome.png'),
                    allow_stretch=True,
                    keep_ratio=False,
                    size=(GetSystemMetrics(0), GetSystemMetrics(1)))
        expl1 = Image(source=os.path.join('assets', 'images',
                                          '67_explanation6.png'),
                      pos_hint={
                          "x": -0.2,
                          "top": 1.2
                      },
                      allow_stretch=True,
                      size_hint=(0.9, 0.9))
        expl2 = Image(source=os.path.join('assets', 'images',
                                          '68_explanation7.png'),
                      pos_hint={
                          "x": -0.1,
                          "top": 0.65
                      },
                      allow_stretch=True,
                      size_hint=(0.7, 0.7))

        vid1 = VideoPlayer(source=os.path.join('assets', 'video',
                                               'resources_imperium.mp4'),
                           pos_hint={
                               "x": 0.5,
                               "top": 0.95
                           },
                           size_hint=(0.4, 0.4),
                           allow_fullscreen=False)
        vid2 = VideoPlayer(source=os.path.join('assets', 'video',
                                               'adding_manpower_imperium.mp4'),
                           pos_hint={
                               "x": 0.5,
                               "top": 0.5
                           },
                           size_hint=(0.4, 0.4),
                           allow_fullscreen=False)

        quit = Button(size_hint=(0.2, 0.1),
                      pos_hint={
                          "x": 0.4,
                          "top": 0.1
                      },
                      background_normal=os.path.join('assets', 'images',
                                                     '26_go_back_u.png'),
                      background_down=os.path.join('assets', 'images',
                                                   '25_go_back_d.png'),
                      on_press=play_sound)
        quit.bind(on_release=self.return_menu)

        self.add_widget(img)
        self.add_widget(expl1)
        self.add_widget(expl2)
        self.add_widget(vid1)
        self.add_widget(vid2)
        self.add_widget(quit)
Exemple #5
0
class VideoPlayerApp(App):

    def build(self):
        filename = 'videoplayback.avi'
        self.layout = GridLayout(cols=2)
        self.video =  VideoPlayer(source=filename, state='play')
        self.layout.add_widget(self.video)
        
        button1 = Button(text='Play video1', font_size=14)
        button1.bind(on_press=self.play_video1)
        button1.size_hint=(0.2,0.1)
        self.layout.add_widget(button1)
        button2 = Button(text='pauza video1', font_size=14)
        button2.size_hint=(0.2,0.1)
        button2.bind(on_press=self.pauza_video1) 
        self.layout.add_widget(button2)
        button3 = Button(text='stop video1', font_size=14)
        button3.size_hint=(0.2,0.1)
        button3.bind(on_press=self.stop_video1) 
        self.layout.add_widget(button3)
        button4 = Button(text='la 1/3 din film', font_size=14)
        button4.size_hint=(0.2,0.1)
        button4.bind(on_press=self.un_sfert_video1) 
        self.layout.add_widget(button4)
        button5 = Button(text='la 2/3 din film', font_size=14)
        button5.size_hint=(0.2,0.1)
        button5.bind(on_press=self.doua_sferturi_video1) 
        self.layout.add_widget(button5)
        button6 = Button(text='volum : -', font_size=14)
        button6.size_hint=(0.2,0.1)
        button6.bind(on_press=self.minus_video1) 
        self.layout.add_widget(button6)
        button7 = Button(text='volum : +', font_size=14)
        button7.size_hint=(0.2,0.1)
        button7.bind(on_press=self.plus_video1) 
        self.layout.add_widget(button7)
        return self.layout
    
    def play_video1 (self,buton):
        self.video.state='play'
    def pauza_video1 (self,buton):
        self.video.state='pause'
    def stop_video1 (self,buton):
        self.video.state='stop'
    def un_sfert_video1 (self,buton):
        self.video.seek(0.33)
    def doua_sferturi_video1 (self,buton):
        self.video.seek(0.66)
    def minus_video1 (self,buton):
        if (self.video.volume>0):
            self.video.volume -=0.1
    def plus_video1 (self,buton):
        if (self.video.volume<1):
            self.video.volume +=0.1
class VideoShotApp(App):
    def build(self):
        return Builder.load_file("ui.kv")

    def on_start(self, *args):
        self.videoplayer = VideoPlayer(source="", allow_fullscreen=False)
        self.root.ids.mainfloat.add_widget(self.videoplayer)
        keyboard.on_press_key("right", self.rightpressed)
        keyboard.on_press_key("left", self.leftpressed)
        keyboard.on_press_key("space", self.spacepressed)

    def rightpressed(self, *args):
        new_value = (((self.videoplayer.position - 0) / (self.videoplayer.duration - 0)) * (1 - 0) + 0) + 0.0019
        self.videoplayer.seek(new_value, precise=True)

    def leftpressed(self, *args):
        new_value = (((self.videoplayer.position - 0) / (self.videoplayer.duration - 0)) * (1 - 0) + 0) - 0.0019
        self.videoplayer.seek(new_value, precise=True)

    def spacepressed(self, *args):
        if self.videoplayer.state == "stop" or self.videoplayer.state == "pause":
            self.videoplayer.state = "play"

        elif self.videoplayer.state == "play":
            self.videoplayer.state = "pause"

    def getFrame(self, ms):
        self.vidcap.set(cv2.CAP_PROP_POS_MSEC, ms)
        hasFrames, image = self.vidcap.read()
        savewindow = Tk()
        savewindow.geometry("0x0")
        filename = filedialog.asksaveasfilename(title='Save Image As',
                                                filetypes=(('JPEG File', '*.jpg'), ('All Files', '*.*')))
        if filename.endswith(".jpg"):
            filename = filename[:-4]
            
        cv2.imwrite(filename + ".jpg", image)  # Save frame as JPG file
        savewindow.destroy()
        return hasFrames

    def screenshot(self, *args):
        ms = self.videoplayer.position * 1000
        self.getFrame(ms)
        
    def loadvideo(self, *args):
        openwindow = Tk()
        openwindow.geometry("0x0")
        openfilename = filedialog.askopenfilename(title="Choose a Video File",
                                                             filetypes=(("MP4 Files", "*.mp4"), ('All Files', '*.*')))
        self.videoplayer.source = openfilename
        self.video = openfilename
        self.vidcap = cv2.VideoCapture(openfilename)
        openwindow.destroy()
Exemple #7
0
 def check_process(self, dt):
     progress = self.th.check_progress()
     if progress > 0.05:
         self.clear_widgets()
         player = VideoPlayer(image_loading = 'spinner.png')
         player.source = 'http://localhost:5001/files/'+self.th.get_biggest_file()['name']
         self.add_widget(player)
     else:
         Clock.schedule_once(self.check_process, 5)
         if progress > 0.008:
             self.clear_widgets()
             n = progress/0.045*100
             self.add_widget(Label(text='Buffering: %.1f' %n))
Exemple #8
0
 def build(self):
     filename = 'videoplayback.avi'
     self.layout = GridLayout(cols=2)
     self.video =  VideoPlayer(source=filename, state='play')
     self.layout.add_widget(self.video)
     
     button1 = Button(text='Play video1', font_size=14)
     button1.bind(on_press=self.play_video1)
     button1.size_hint=(0.2,0.1)
     self.layout.add_widget(button1)
     button2 = Button(text='pauza video1', font_size=14)
     button2.size_hint=(0.2,0.1)
     button2.bind(on_press=self.pauza_video1) 
     self.layout.add_widget(button2)
     button3 = Button(text='stop video1', font_size=14)
     button3.size_hint=(0.2,0.1)
     button3.bind(on_press=self.stop_video1) 
     self.layout.add_widget(button3)
     button4 = Button(text='la 1/3 din film', font_size=14)
     button4.size_hint=(0.2,0.1)
     button4.bind(on_press=self.un_sfert_video1) 
     self.layout.add_widget(button4)
     button5 = Button(text='la 2/3 din film', font_size=14)
     button5.size_hint=(0.2,0.1)
     button5.bind(on_press=self.doua_sferturi_video1) 
     self.layout.add_widget(button5)
     button6 = Button(text='volum : -', font_size=14)
     button6.size_hint=(0.2,0.1)
     button6.bind(on_press=self.minus_video1) 
     self.layout.add_widget(button6)
     button7 = Button(text='volum : +', font_size=14)
     button7.size_hint=(0.2,0.1)
     button7.bind(on_press=self.plus_video1) 
     self.layout.add_widget(button7)
     return self.layout
Exemple #9
0
    def build(self):
        self.player = VideoPlayer(
            source='/users/vinodh/downloads/Sintel_DivXPlus_6500kbps.mkv',
            state='stop',
            options={'allow_stretch': True})

        return (self.player)
 def build(self):
     if len(argv) > 1:
         filename = argv[1]
     else:
         curdir = dirname(__file__)
         filename = join(curdir, 'Coldplay - Up and Up.mp4')
     return VideoPlayer(source=filename, state='play')
Exemple #11
0
 def __init__(self, **kwargs):
     super(MyW, self).__init__(**kwargs)
     player = VideoPlayer(source='GOR.MOV',
                          state='play',
                          options={'allow_stretch': True},
                          size=(600, 600))
     self.add_widget(player)
Exemple #12
0
    def login(self, *args):
        from kivy.storage.jsonstore import JsonStore
        import mysql
        connection = mysql.connect('127.0.0.1',
                                   '8080',
                                   password='******',
                                   db='accounts',
                                   username='******')
        con = connection.execute()
        store = JsonStore('account.json')
        if str(self.n_username.text) and str(self.n_email.text) and str(
                self.n_phone) and str(self.n_password):
            store.put('credentilas',
                      user=self.n_username.text,
                      email=self.n_email.text,
                      phone=self.n_phone.text,
                      password=self.n_password.text)
            if True:
                co = VideoPlayer(source='video/video2.avi',
                                 state='play',
                                 volume=1)
                q = Popup(title='details',
                          title_align='center',
                          content=co,
                          size_hint=(1, 1))
                q.open()
                Clock.schedule_once(q.dismiss, 40)

        else:
            co = Label(text='retry')
            e = Popup(title='error will uploading check your details',
                      title_color=[1, 0, 1, 1],
                      content=co,
                      size_hint=(.2, .2)).open()
            Clock.schedule_once(e.dismiss, .90)
 def build(self):
     if len(argv) > 1:
         filename = argv[1]
     else:
         curdir = dirname(__file__)
         filename = join(curdir, 'softboy.avi')
     return VideoPlayer(source=filename, state='play')
Exemple #14
0
    def __init__(self, **kwargs):
        self.vedio_name
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 1

        self.inside = GridLayout()
        self.inside.cols = 3

        self.title = Label(text="what do you think ... ? ")
        self.inside.add_widget(self.title)

        self.inside.inside = GridLayout()
        self.inside.inside.rows = 2
        self.description = TextInput(multiline=True)
        self.inside.inside.add_widget(self.description)

        self.inside.inside.inside = GridLayout()
        self.inside.inside.inside.cols = 2
        # size_hint_max_y= 0.5
        self.visualize = Button(text="Animate", font_size=15)
        self.visualize.bind(on_press=self.play)
        self.inside.inside.inside.add_widget(self.visualize)

        self.clear = Button(text="clear", font_size=15)
        self.clear.bind(on_press=self.pressed)
        self.inside.inside.inside.add_widget(self.clear)

        self.inside.inside.add_widget(self.inside.inside.inside)
        self.inside.add_widget(self.inside.inside)
        self.add_widget(self.inside)

        self.player = VideoPlayer(source=self.vedio_name,
                                  state='stop',
                                  options={'allow_stretch': True})
        self.add_widget(self.player)
Exemple #15
0
def videoArchiveBtnCallback(self):
        setDisplaySleepTime(9999,1)
        data = getVideoList()
        listData = []
        for d in data:
                listData.append(d.id + "  " + d.time.strftime('%d. %b - %H:%M:%S'))

        list_adapter = ListAdapter(data=listData,
                           cls=VideoListItemButton,
                           selection_mode='single',
                           allow_empty_selection=False)
        player = VideoPlayer(source=data[0].path, state='play', options={'allow_stretch': True})
        root = GridLayout(cols=2)
        popup = Popup(title='Video archív  -  '+data[0].time.strftime('%d. %b - %H:%M:%S'),
                    content=root,
                    size_hint=(1, 1))
        list_adapter.bind(on_selection_change=partial(videoArchiveItemSelected,player, popup))
        
        
        layout1 = BoxLayout(orientation='vertical')
        layout2 = BoxLayout(orientation='vertical')
        videoList = ListView(adapter=list_adapter)
        btn = Button(text='Zatvoriť', size_hint_y=0.2)
        layout1.add_widget(videoList)
        layout2.add_widget(player)
        layout2.add_widget(btn)
        root.add_widget(layout1)
        root.add_widget(layout2)
        
        btn.bind(on_press=partial(videoArchiveExitBtnCallback,popup))
        popup.open()
Exemple #16
0
 def play_on_enter(self, vidname):
     self.vid = VideoPlayer(source=vidname, state='play',
                         options={'allow_stretch':False,
                                 'eos': 'loop'})
     popup = Popup(title=vidname, content=self.vid)
     popup.bind(on_dismiss=lambda x:self.stop_video())
     popup.open()
Exemple #17
0
 def on_affiche_video(self, nom_video, video):
     if not video: return
     self.playing_video = VideoPlayer(source=video[0].path, state='play')
     self.popup.content = self.playing_video
     # On arrête les enregistrements quand on affiche une vidéo
     # TODO: savoir si on le fait vraiment ou pas!
     self.play_video(False)
     self.popup.open()
Exemple #18
0
 def build(self):
     if len(argv) > 1:
         filename = argv[1]
     else:
         print('Usage: python %s VIDEO_FILE_PATH' %
               os.path.basename(sys.argv[0]))
         sys.exit(1)
     return VideoPlayer(source=filename, state='stop')
Exemple #19
0
 def switch_video_file(self, file_path):
     # TODO: check if file is valid video file via 'if' statement or 'try except'
     self.video_file_path = file_path
     if self.tab == 1:  # or self.tab == 2:
         self.video_main.clear_widgets()
         self.video_main.player = VideoPlayer(source=file_path,
                                              state='play')
         self.video_main.add_widget(self.video_main.player)
Exemple #20
0
    def build(self):
        self.player = player = VideoPlayer(
            source=os.environ['__KIVY_VIDEO_TEST_FNAME'], volume=0)

        self.player.fbind('position', self.check_position)
        Clock.schedule_once(self.start_player, 0)
        Clock.schedule_interval(self.stop_player, 1)
        return player
Exemple #21
0
    def build(self):

        self.player = VideoPlayer(
            source='/users/shangqunyu/Downloads/videoplayback.mp4',
            state='stop',
            options={'allow_stretch': True})

        return self.player
Exemple #22
0
	def play_video(self, selection):
		try:
			filename = selection[0]
			self.videoPlayer = VideoPlayer(source=filename, state='play', thumbnail='data/images/image-loading.gif')
			self.popup = Popup(content=self.videoPlayer, size_hint=(.9, .9), title=filename)
			self.popup.bind(on_dismiss=self.stop_video)
			self.popup.open()
		except:
			pass
Exemple #23
0
 def build(self):
     self.label = Label(text='Share some text or video with me')
     self.video = VideoPlayer()
     box = BoxLayout(orientation='vertical')
     box.add_widget(self.video)
     box.add_widget(self.label)
     self.share_listener = ShareRcv(text_callback=self.new_text,
                                    video_callback=self.new_video)
     return box
Exemple #24
0
 def test_on_enter(self, vidname):
     #self.add_widget(Button(text="Back"))
     self.vid = VideoPlayer(source=vidname,
                            state='play',
                            options={
                                'allow_stretch': False,
                                'eos': 'loop'
                            })
     self.add_widget(self.vid)
Exemple #25
0
    def build(self):
        self.theme_cls.theme_style = "Dark"
        self.theme_cls.primary_palette = "BlueGray"

        # Create videoPlayer Instance
        player = VideoPlayer(source="videos/intro.mp4")

        # Assign VideoPlayer State
        player.state = 'play'

        # Set options
        player.options = {'eos': 'loop'}

        # Allow stretch
        player.allow_stretch = True

        # Return player
        return player
Exemple #26
0
	def build(self):
		scraper = VideoScraper.GetVideoScraper()
		thread = VideoLinkScraperThread('http://kissanime.to/Anime/Haikyuu-Third-Season/Episode-005?id=131750', scraper)
		thread.start()
		while thread.isAlive():
			time.sleep(1)
		print(thread.videoLinks) 
		print('loading ', thread.videoLinks[0][0])
		player = VideoPlayer(source=thread.videoLinks[0][0], state='play',options={'allow_stretch': True})
		return player
Exemple #27
0
 def on_button_press2(self, buton):
     self.parent.clear_widgets()
     self.layout3 = GridLayout(cols=2)
     menuBack = Button(text='Menu', font_size=14)
     menuBack.size_hint = (0.1, 0.1)
     menuBack.bind(on_press=self.Menu)
     self.layout3.add_widget(menuBack)
     self.video2 = VideoPlayer(source='videoplayback.avi', state='play')
     self.layout3.add_widget(self.video2)
     self.parent.add_widget(self.layout3)
     return self.parent
Exemple #28
0
    def on_enter(self):
        vp = VideoPlayer(source=os.path.join("videos",
                                             "gvr_pycon2014_keynote_kivy.mp4"),
                         options={'allow_stretch': True})
        self.ids.video_ai.add_widget(vp)

        with open(os.path.join("slides", "whatiskivy.kv"), 'r') as kv_file:
            self.ids.kv_demo.text = kv_file.read()

        with open(os.path.join("snippets", "minimal_app.txt"), 'r') as py_file:
            self.ids.min_app.text = py_file.read()
Exemple #29
0
 def load(self, path, filename):
     with open(os.path.join(path, filename[0])) as stream:
         video = 'stream.avi'
         w = VideoPlayer(source='video',
                         volume=1,
                         state='play',
                         size_hint=(1, 1),
                         pos_hint={'top': 1},
                         background_color=[1, 1, 1, 0],
                         options={'allow_stretch': 'True'})
         self.videowidget.add_widget(w)
     self.dismiss()
Exemple #30
0
	def on_touch_down(self,touch):
		if 'markerid' in touch.profile:
			if touch.fid==5:
				with self.canvas.before:
					filename= 'sher.mp4'
					VideoPlayer(source=filename,state='play')	
					
			#		Rectangle(source="sher.mp4",pos=self.pos,size=self.size)
					#self.add_widget(Rectangle(source="download.jpeg"))
			elif touch.fid==6:
				with self.canvas.before:
					Rectangle(source="perspective1.png",pos=self.pos,size=self.size)
Exemple #31
0
    def __init__(self, filename, **kwargs):
        super(AppBase, self).__init__(**kwargs)
        self.padding = 20

        self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text')
        self._keyboard.bind(on_key_down=self._on_keyboard_down)

        self.v = VideoPlayer(source=filename, state='stop')
        self.add_widget(self.v)

        self.label = Label()
        self.label.pos_hint = {'center_x': .8, 'center_y': .8}
        self.label.color = (0, 255, 0, 1)
        self.label.font_size = '30sp'
        self.add_widget(self.label)
        self.rect_label = None

        self.time_label = Label(pos_hint={'center_x': .3, 'center_y': .2},
                                font_size='20sp',
                                color=(1, 1, 1, 1))
        self.add_widget(self.time_label)

        self.rect_label = Label(pos_hint={'center_x': .5, 'center_y': .5},
                                text='',
                                font_size='50sp',
                                color=(1, 1, 1, 1))
        self.add_widget(self.rect_label)

        self.rect = None
        self.value = 0.0

        self.last_position = None
        self.frameGaps = collections.deque([0.1], maxlen=10)
        self.framegap = 0.0
        self.updated = False
        self.customspeed = False
        self.speed = 2.0

        self.draw_rect = False
        self.bind(pos=self.on_resize, size=self.on_resize)
    def __init__(self, **kwargs):
        # 父类构造方法
        super().__init__(**kwargs)

        # 视频播放器
        player = VideoPlayer(source='demo0.mp4',
                             state='play',
                             options={
                                 'allow_stretch': True,
                                 'eos': 'loop'
                             })
        # 布局加组件(视频播放器)
        self.add_widget(player)
Exemple #33
0
 def run_main(self):
     files = []
     for item in self.table.all():
         files.append(item['filename'])
     self.pr = vmet.Processor(files, self.img_count)
     filename = str(self.manager.current) + 'VirtualEnsemble' + '.mp4'
     self.pr.run_app(filename)
     vid = VideoPlayer(source='./'+filename, state='play',
                         options={'allow_stretch':False,
                                 'eos': 'loop'})
     finalPop = Popup(title=filename, content=vid,
                     size_hint=(None,None), size=(500,500))
     finalPop.bind(on_dismiss=lambda x:self.stop_video(vid))
     finalPop.open()
Exemple #34
0
    def __init__(self, **kwargs):
        super(FourthScreen, self).__init__(**kwargs)

	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        self.add_widget(btnRight)
        self.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source='Momona.mp4')
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        self.add_widget(graph)
        self.add_widget(video)
Exemple #35
0
class AppBase(RelativeLayout):
    def __init__(self, filename, **kwargs):
        super(AppBase, self).__init__(**kwargs)
        self.padding = 20

        self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text')
        self._keyboard.bind(on_key_down=self._on_keyboard_down)

        self.v = VideoPlayer(source=filename, state='stop')
        self.add_widget(self.v)

        self.label = Label()
        self.label.pos_hint = {'center_x': .8, 'center_y': .8}
        self.label.color = (0, 255, 0, 1)
        self.label.font_size = '30sp'
        self.add_widget(self.label)
        self.rect_label = None

        self.time_label = Label(pos_hint={'center_x': .3, 'center_y': .2},
                                font_size='20sp',
                                color=(1, 1, 1, 1))
        self.add_widget(self.time_label)

        self.rect_label = Label(pos_hint={'center_x': .5, 'center_y': .5},
                                text='',
                                font_size='50sp',
                                color=(1, 1, 1, 1))
        self.add_widget(self.rect_label)

        self.rect = None
        self.value = 0.0

        self.last_position = None
        self.frameGaps = collections.deque([0.1], maxlen=10)
        self.framegap = 0.0
        self.updated = False
        self.customspeed = False
        self.speed = 2.0

        self.draw_rect = False
        self.bind(pos=self.on_resize, size=self.on_resize)

    def _keyboard_closed(self):
        print('My keyboard have been closed!')
        self._keyboard.unbind(on_key_down=self._on_keyboard_down)
        self._keyboard = None

    def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
        # print 'The key', keycode[1], 'have been pressed'
        # print(' - text is %r' % text)
        # print(' - modifiers are %r' % modifiers)

        if keycode[1] == 'h':
            self.draw_rect = True
        elif keycode[1] == 'g':
            self.draw_rect = False
        elif keycode[1] == 's':
            self.custom_play_pause()
        elif keycode[1] == 'left':
            self.play_pause(force=True)
            self.step_video(False)
            self.label.text = "<< Step backward"
        elif keycode[1] == 'right':
            self.play_pause(force=True)
            self.step_video(True)
            self.label.text = "Step forward >>"
        elif keycode[1] == 'spacebar':
            self.play_pause()
        elif keycode[1] == 'enter':
            self.v.state = 'stop'
            self.v.seek(0.0)
            self.label.text = ''
        elif keycode[1] == 'escape':
            sys.exit(1)
        elif keycode[1] == 'pageup':
            if self.speed < 16.0:
                self.speed *= 2.0
                if self.speed == 1.0:
                    self.speed = 2.0
        elif keycode[1] == 'pagedown':
            if self.speed > 1.0 / 16.0:
                self.speed /= 2.0
                if self.speed == 1.0:
                    self.speed = 0.5
        # Return True to accept the key. Otherwise, it will be used by
        # the system.
        return True

    def play_pause(self, force=False):
        if force:
            Clock.unschedule(self.update)
            Clock.unschedule(self.custom_update)
            self.v.state = 'pause'
            self.customspeed = False
            self.label.text = 'Pause ||'
        else:
            if self.customspeed:
                self.custom_play_pause()
            if self.v.state == 'play':
                self.v.state = 'pause'
                Clock.unschedule(self.update)
                self.label.text = 'Pause ||'
            else:
                self.v.state = 'play'
                Clock.schedule_interval(self.update, 0.0)  # Schedule at max interval (once per frame)
                self.label.text = 'Play >'

    def custom_play_pause(self):
        if self.v.state == 'play':
            self.play_pause()
        if self.customspeed is False:
            self.customspeed = True
            Clock.schedule_interval(self.custom_update, 0.0)
        else:
            self.customspeed = False
            Clock.unschedule(self.custom_update)
            self.label.text = 'Pause ||'

    def step_video(self, direction, step_size=0.05):
        if direction:
            self.value = (self.v.position + step_size) / self.v.duration
        else:
            self.value = (self.v.position - step_size) / self.v.duration
        self.v.seek(self.value)
        self.tickReset()
        self.on_draw()

    def on_draw(self):
        if self.rect is None and self.draw_rect:
            with self.canvas:
                Color(1, 0, 0, 0.3, mode='rgba')
                self.rect = Rectangle(pos=(self.padding, self.padding),
                                      size=(self.width - 2 * self.padding, self.height - 2 * self.padding))
                self.rect_label.text = 'Objects'
        elif self.rect is not None and not self.draw_rect:
            self.canvas.remove(self.rect)
            self.rect_label.text = ''
            self.rect = None
            # self.canvas.clear()

        self.time_label.text = "Time: %.4f" % self.v.position
        # print self.rect_label is None

    def on_resize(self, *args):
        if self.rect is not None:
            self.rect.pos = (self.padding, self.padding)
            self.rect.size = (self.width - 2 * self.padding, self.height - 2 * self.padding)

    def tick(self):
        if self.last_position is None:
            self.last_position = self.v.position
        else:
            if self.v.position > self.last_position:
                self.frameGaps.append(self.v.position - self.last_position)
                self.last_position = self.v.position
                self.updated = True

    def _frameGap(self):
        if self.updated:
            self.framegap = np.mean(self.frameGaps)
            self.updated = False

    def tickReset(self):
        '''To prevent frame calculation error when custom play'''
        self.last_position = None

    def update(self, dt):
        self.tick()
        self.on_draw()

    def custom_update(self, dt):
        if self.v.position + 0.5 > self.v.duration:
            self.tickReset()
            self.play_pause()
        else:
            self._frameGap()
            self.step_video(True, step_size=self.framegap * self.speed)
            if self.speed > 1:
                self.label.text = 'Custom speed x %d ' % int(self.speed)
            else:
                self.label.text = 'Custom speed x 1/%d ' % int(1/self.speed)
Exemple #36
0
    def playVideo(self,FourthScreen):
	#get data for patient
	with open('choosePatient.txt','r') as f:
      	    patientName=f.read()
#      	data = data.split(',')
      	fileName ='videos/' + patientName + ".mp4"
	
	dataMatrix1 = genfromtxt('DemoEEGFile.txt')
	x = dataMatrix1[:,0]
	x = x - 5.539
	y = dataMatrix1[:,1]
	
	xmin = math.trunc(x[0])
	ymin = math.trunc(min(y))#math.trunc(y[0])
	xmax = xmin+1
	xGlobalmax = math.trunc(x[len(x)-1])
	ymax = math.trunc(max(y))#math.trunc(y[len(y)-1])
	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        FourthScreen.add_widget(btnRight)
        FourthScreen.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source=fileName)
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        FourthScreen.add_widget(graph)
        FourthScreen.add_widget(video)