在 Kivy 中嵌入 youtube 视频

2022-01-15 00:00:00 python kivy video-streaming

问题描述

我想使用 youtube URL 在 Kivy 的小部件中嵌入视频.那可能吗 ?该文档提供了 VideoPlayer 的示例 - http://kivy.org/docs/api-kivy.uix.videoplayer.html 但它只用于播放本地文件.

I want to embed videos in a widget in Kivy using youtube URLs. Is that possible ? The documentation gives example for VideoPlayer - http://kivy.org/docs/api-kivy.uix.videoplayer.html but its only for playing local files.


解决方案

Kivy 可以从互联网上串流视频并在 VideoPlayer 中播放.但是,YouTube 不提供流式传输 URL.请记住,YouTube 只有在展示广告时才会获得报酬,这意味着他们希望您访问他们的网站并需要您使用他们的视频播放器.

Kivy can stream videos from the internet and play them in VideoPlayer. However, YouTube does not provide a streaming URL. Remember that YouTube only gets paid when they show ads, which means they want you on their site and need you to use their video player.

我能想到两个选择:

  1. 使用 YouTube 下载器应用来检索视频(或者,尝试破解其中一个下载器,看看您是否能弄清楚他们在做什么以及如何在 Kivy 中复制它).
  2. 使用 Chromium Embedded Framework 显示实际网页.我不知道这是否适用于 Flash,但理论上它适用于任何 HTML5 视频(但并非所有视频都可以在 HTML5 中观看).有一个 CEFPython Garden 小部件 可用,以及一个非花园 CEFKivy 组件 有更新的发展.
  1. Use a YouTube downloader app to retrieve the video (or, alternatively, try to hack on one of the downloaders and see if you can figure out what they're doing and how to duplicate it in Kivy).
  2. Use the Chromium Embedded Framework to display an actual web page. I have no idea whether this will work with Flash or not, but in theory it would work for any HTML5 videos (but not all videos can be watched in HTML5). There is a CEFPython Garden widget available, as well as a non-Garden CEFKivy component which has more recent development.

相关文章