有没有可能在kivy中播放一段视频(mp4)作为背景?我正在使用下面的代码,但不加载视频。。。。。在
__author__ = 'kshk'
import kivy
kivy.require('1.8.0')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.video import Video
class Dashboard(GridLayout):
def __init__(self, **kwargs):
super(Dashboard,self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text="Login"))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
self.add_widget(Label(text="Password"))
self.password = TextInput(password=True,multiline=False)
self.add_widget(self.password)
self.video = Video(source="/tmpt/driver.mp4")
self.add_widget(self.video)
class MyApp(App):
def build(self):
return Dashboard()
if __name__ == '__main__':
MyApp().run()
更新:
日志:
^{pr2}$更新: 现在我正在尝试使用AnchorLayout,在背景中添加视频,在前面使用GridLayout。。。。在
main.py
__author__ = 'kshk'
import kivy
kivy.require('1.8.0')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.video import Video
from kivy.uix.widget import Widget
from kivy.uix.anchorlayout import AnchorLayout
class MyWidget(Widget):
pass
class WidgetsApp(App):
def build(self):
return MyWidget()
if __name__ == '__main__':
WidgetsApp().run()
widgets.kv
#File widgets.kv
#:kivy 1.8.0
<MyWidget>:
AnchorLayout:
Video:
source: 'driver.avi'
size: 100,100
GridLayout:
Button:
text: 'Hello'
pos: 0,100
size: 100, 50
color: .8, .9, 0, 1
font_size: 32
Button:
text: 'World!'
pos: 100,0
size: 100, 50
color: .8, .9, 0, 1
font_size: 32
我只得到一个黑屏!。。。在
更新:
我指出了这个错误…你知道如何得到这个插件吗?我已经安装了gstreamer。在
[DEBUG ] [VideoPyGst ] Load <driver.mp4>
** Message: don't know how to handle video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)4.2, profile=(string)main, width=(int)1920, height=(int)1080, framerate=(fraction)2997/125, pixel-aspect-ratio=(fraction)1/1, parsed=(boolean)true
[ERROR ] [VideoPyGst ] There is no codec present that can handle the stream's type.
[DEBUG ] [VideoPyGst ] gstplaybasebin.c(2323): prepare_output (): /GstPlayBin:playbin
[ERROR ] [VideoPyGst ] GStreamer encountered a general stream error.
[DEBUG ] [VideoPyGst ] qtdemux.c(3891): gst_qtdemux_loop (): /GstPlayBin:playbin/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-linked
[INFO ] [Base ] Leaving application in progress...
更新:
关于femac的问题,看起来像是femac的问题
是的,只要把视频放在你想显示的任何东西后面。您的示例不会这样做,因为它是gridlayout的一部分,您可能想做一些事情,比如使用AnchorLayout将两个孩子放在同一个地方(这不是唯一的方法,但很简单)。在
至于你的视频为什么不显示,我不知道。您确定文件路径有效吗?你在候机楼里有关于它的日志吗?在
回答这个问题,可能是因为你没有把这个文件链接到屏幕上。这两个文件的链接应该Builder.load_文件().. 在
例如。。在
希望这能有所帮助。在
相关问题 更多 >
编程相关推荐