問題描述
我想使用 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.
我能想到兩個選擇:
- 使用 YouTube 下載器應用來檢索視頻(或者,嘗試破解其中一個下載器,看看您是否能弄清楚他們在做什么以及如何在 Kivy 中復制它).
- 使用 Chromium Embedded Framework 顯示實際網頁.我不知道這是否適用于 Flash,但理論上它適用于任何 HTML5 視頻(但并非所有視頻都可以在 HTML5 中觀看).有一個 CEFPython Garden 小部件 可用,以及一個非花園 CEFKivy 組件 有更新的發展.
- 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).
- 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.
這篇關于在 Kivy 中嵌入 youtube 視頻的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!