問題描述
我正在開發用于播放 YouTube 視頻的 Windows Mobile 6(或也許 5)應用程序.好吧,它應該播放 YouTube 視頻(并控制/查詢播放器的狀態變化、當前幀/時間等)
I am working on an application for Windows Mobile 6 (or maybe 5) that plays YouTube videos. Well, it should play YouTube videos (and control/query the player about status changes, current frame/time, etc.)
在網上搜索了相當長的一段時間(并進行了幾次嘗試)后,我仍然找不到這樣做的方法.我知道的選項是:
After scouring the web for quite some time now (and a few trials), I still couldn't find a way to do this. The options I know of are:
使用嵌入在 HTML 中、可通過 JavaScript 控制的 YouTube 播放器.但是,我無法從 IE Mobile 觀看 YT 視頻,首先 - 我收到一條錯誤消息,內容類似于您需要啟用了 Flash Player 8 和 JavaScript 的瀏覽器".
Use the YouTube player, embedded in HTML, controllable via JavaScript. However, I couldn't watch YT videos from IE Mobile, to begin with -- I get an error message saying something along the lines of "you need a browser with Flash Player 8 and JavaScript enabled".
托管媒體播放器控件,但 WMP 拒絕播放 YT 視頻,包括移動格式.
Host a Media Player control, but WMP refuses to play YT videos, including the Mobile format.
使用 DirectShow.我仍在研究這個(我以前從未使用過 COM,更不用說 DirectShow),但我還沒有找到支持 YouTube 的格式
Use DirectShow. I'm still looking into this one (I've never worked with COM, let alone DirectShow, before), but I am yet to find a solution that supports YouTube's format(s)
我寧愿用 C# 編寫這個應用程序,但 C++ 也可以.
I would rather write this application in C#, but C++ works, too.
幫助我,StackOverflow 的智者!
Help me, O Wise Sages of StackOverflow!
推薦答案
您還可以將 YouTube 視頻抓取為 MP4,希望能擴展您的播放器選項.您可以查看 DirectShow CF 的播放功能,或者在您的應用中托管其他一些支持 MP4 或 FLV 的播放器.
You can also grab YouTube videos as MP4, hopefully that expands your player options. You can look into DirectShow CF for playback functionality, or host some other player in your app that supports MP4 or FLV.
嘗試通過移動 IE 播放它不起作用,因為支持視頻播放的 Flash 插件所需的版本不可用(我上次檢查過).
Trying to play it back through IE mobile won't work, as the version necessary of the Flash plug-in with video playback support isn't available (last time I checked).
要獲取 MP4 文件,請向此 URL 發出請求:
"http://www.youtube.com/get_video?video_id=" +videoID + "&t=" + 令牌 + "&fmt=18"
"http://www.youtube.com/get_video?video_id=" + videoID + "&t=" + token + "&fmt=18"
要獲取 FLV,請使用:
"http://www.youtube.com/get_video?video_id=" +videoID + "&t=" + 令牌
"http://www.youtube.com/get_video?video_id=" + videoID + "&t=" + token
要獲取令牌,請調用:
"http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=" + videoID
"http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=" + videoID
我編寫了一個應用程序,可以抓取 YouTube 視頻的播放列表并將它們與我的 PocketPC 同步,我使用 TCPMP 和 Flash 插件來播放視頻(從我的應用程序外部).雖然 MP4 也適用于 PPC,但我堅持使用 FLV,因為當時 YouTube 上的某些視頻無法作為 MP4 使用.我現在不會擔心這個.
I wrote an app that would grab a playlist of YouTube videos and sync them up with my PocketPC, I used TCPMP with the Flash add-on to playback the video (externally from my app). Although MP4 also worked on the PPC, I stuck to FLVs because at the time some videos on YouTube were not available as MP4. I wouldn't be concerned about this now.
遺憾的是我的 PPC 壞了,現在我在 iPhone 上做了類似的事情,但我不得不完全切換到 MP4 格式.VLC 在 iPhone 上的 FLV 播放對我來說太生澀了.
Sadly my PPC broke, now I'm doing something similar on my iPhone but I had to switch completely to the MP4 format. VLC's FLV playback on the iPhone was too jerky for me.
這篇關于在 Windows Mobile 應用程序中播放 YouTube 視頻的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!