问题
i want to put a video inside a canvas.
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.
this is my code for the image :
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
回答1:
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
来源:https://stackoverflow.com/questions/60485905/kivy-putting-video-inside-a-canvas