Cyclonus Cyclonus - 2 months ago 23
Python Question

Kivy VideoPlayer fullscreen, loop, and hide controls

I'm just starting out with Kivy, so please point out if I'm doing something wrong.. I'm trying to work with the video player. Namely, I can't seem to get it to recognize any "options", and I'd really like a way to hide the controls (to prevent the user from stopping/pausing/changing volume/interacting etc.. while the movie is running).

Here's what I've got so far:

import kivy
kivy.require('1.9.0')

from kivy.app import App
from kivy.uix.videoplayer import VideoPlayer

class MyApp(App):
def build(self):
self.player = VideoPlayer(fullscreen=True, allow_fullscreen=True, source='mymovie.mp4', state='play', options={'allow_stretch': True, 'eos': 'loop', 'fullscreen': True})
return(self.player)


if __name__ == '__main__':
MyApp().run()


eos: 'loop' above, seems to be completely ignored. As does 'fullscreen'. Double clicking the player doesn't cause it to run in full screen.

I'm testing on Windows (but hoping to port to android), and in the "console" window in the background I have 2 warnings that should help me, but I guess I don't know enough to know how to take care of it:

[WARNING ] [VideoPlayer ] Cannot switch to fullscreen, window not found.
[WARNING ] [VideoPlayer ] Cannot switch to fullscreen, window not found.


Ideally, I would get it running in fullscreen and would be able to disable the controls (so the user can interact with things using keyboard/touch/timer events/etc.) but I can't find any documentation on how to disable them. Any pointers?

I've managed to get the window itself to run in fullscreen, but that's not the same thing, I don't think.
Thanks!

Answer

I solved my issues by using kivy.uix.video.Video instead of kivy.uix.videoplayer.VideoPlayer. I don't know if that's what I was expected to do in the first place (just starting out!), but just in case someone else has this problem, here's what worked for me:

import kivy
kivy.require('1.9.0')

from kivy.app import App
from kivy.uix.video import Video

class MyApp(App):
    def build(self):
        video = Video(source='mymovie.mp4')
        video.state='play'
        video.options = {'eos': 'loop'}
        video.allow_stretch=True
        return video

if __name__ == '__main__':
    MyApp().run()
Comments