Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
795 views
in Technique[技术] by (71.8m points)

windows 8 - How to play YouTube videos in a Windows8 html/javascript app?

How can I play YouTube videos in a Windows 8 html/javascript app? I have the clip's id and I just want to play it. Perhaps via html5's video tag?

I've tried the iframe api, but failed to get it to work. I've also made a try on the javascript api, but it failed to load javascript from anther location.

Any help on the subject would be very appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I developed a YouTube class for Windows Phone which gets the MP4 link of a YouTube movie. Maybe you can use this code and start the video app with the MP4 link or set the source of a media element (if existent in Win8)?

If there's a way to start the video app with a predefined MP4-URL I can rewrite the code for Windows 8.

http://mytoolkit.codeplex.com/wikipage?title=YouTube

UPDATE: I've updated the code. Now simply load the URL with this async method:

var url = await YouTube.GetVideoUriAsync("youtube_id");
myMediaElement.Source = url.Uri;

myMediaElement is a XAML MediaElement control.

Check out the whole library from the project's Subversion repository: http://mytoolkit.codeplex.com

Update: Sorry it's C# only, you have to port it to Javascript...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...