问题描述
我只是从Kivy开始,所以请指出我做错了什么..我正在尝试与视频播放器一起使用.也就是说,我似乎无法识别任何选项",并且我真的很想隐藏控件(以防止用户在电影播放时停止/暂停/更改音量/进行交互等方式).正在运行).
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:上面的循环",似乎被完全忽略了.和全屏"一样.双击播放器不会使其全屏运行.
eos: 'loop' above, seems to be completely ignored. As does 'fullscreen'. Double clicking the player doesn't cause it to run in full screen.
我正在Windows上进行测试(但希望移植到android),并且在后台的控制台"窗口中有2条警告应该对我有帮助,但是我想我不知道该怎么做照顾它:
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!
推荐答案
我通过使用kivy.uix.video.Video
而不是kivy.uix.videoplayer.VideoPlayer
解决了我的问题.我不知道那是我最初应该做的(只是开始!),但是以防万一有人遇到这个问题,这对我有用:
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()
这篇关于Kivy VideoPlayer全屏,循环和隐藏控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!