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
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'