-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
other_video_player.py
50 lines (38 loc) · 997 Bytes
/
other_video_player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from kivy.app import App
from kivy.uix.video import Video
from kivy.lang import Builder
kv = """
BoxLayout:
orientation: 'vertical'
Player:
id:player
BoxLayout:
size_hint_y: .1
Button:
text: 'play'
on_release: player.state = 'play'
"""
video_list = ['IMG_1853.jpg',
'Hand Washing - 34091.mp4']
class Player(Video):
def __init__(self, **kwargs):
self.v = 0
super().__init__(source=video_list[0], state='stop', **kwargs)
def on_eos(self, *args):
print(f'on_eos: {self.eos} loaded: {self.loaded}, state: {self.state}')
if self.eos:
self.v += 1
if self.v == len(video_list):
print('End of playlist')
self.v = 0
return
self.source = video_list[self.v]
self.state = 'play' # must set state to play for video to be loaded
def on_loaded(self, *args):
# print('*' * 80)
print(f'loaded: {self.loaded}')
class VideoPlayerApp(App):
def build(self):
return Builder.load_string(kv)
if __name__ == '__main__':
VideoPlayerApp().run()