猕猴桃把视频放到画布上吗? [英] kivy putting video inside a Canvas?

查看:66
本文介绍了猕猴桃把视频放到画布上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将视频放在画布中.

i want to put a video inside a canvas.

我在其中使用图像很好,但是当我使用视频时会触发一些错误.Unknown <mp4> type, no loader found.我不知道问题出在哪里.

i'm using images inside them just fine but when i use videos it triggers some errors Unknown <mp4> type, no loader found. i do not know where is the probleme.

这是我的图片代码:

with self.canvas:
            self.bg = Rectangle(source='mahrez.jpg', pos=self.pos, size=self.size)

但是我要使用视频而不是图像

but instead of the image i want to use a video

推荐答案

您可以通过使用kivy.core.video并使用它来设置Rectangle的纹理来完成所需的操作:

You can do what you want by using kivy.core.video and using that to set the texture of the Rectangle:

from kivy.core.video import Video as CoreVideo
.
.
.
    with self.canvas:
        self.bg = Rectangle(source='mahrez.jpg', pos=self.pos, size=self.size)
    self.video = CoreVideo()
    self.video.bind(on_frame=self.set_bg_texture)
    self.video.filename = 'BigBuckBunny.mp4'

    # just a delay to show that the original image is shown first
    Clock.schedule_once(self.start_vid, 3)

def start_vid(self, dt):
    self.video.play()

def set_bg_texture(self, *args):
    self.bg.texture = self.video.texture

这篇关于猕猴桃把视频放到画布上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆