Playing Youtube Video In Windows 8 App
I have been trying to play a youtube video in a windows 8 html5 & javascript app with no luck! I tried copy pasting the code youtube provided for embedding videos in the body o
Solution 1:
YouTube has a beta program to provide some videos in HTML5. You can join it here . Once you have done that you should be able to embed HTML5 YouTube videos in a WebView control by navigating to the YouTube URL.
Flash videos cannot be displayed in a Metro style app.
Code for the webview control
string htmlFragment =
@"<!DOCTYPE htmlPUBLIC'-//W3C//DTD XHTML 1.0 Transitional//EN''http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html><head><title>YouTubePagesample</title></head><iframewidth='560'height='315'src='http://www.youtube.com/embed/{YoutubeID}'frameborder='0'allowfullscreen></iframe><body></body></html>;";
this.webView.NavigateToString(htmlFragment);
Solution 2:
Use the setInnerHTMLUnsafe method as win 8 apps don't like the external JS being injected in the app. videoPlayer is the div which you want to add the embed to.
var content = '<iframewidth="480"height="270"src="http://www.youtube.com/embed/8sPj0Ic8KQ8?rel=0"frameborder="0"allowfullscreen></iframe>' ;
WinJS.Utilities.setInnerHTMLUnsafe(videoPlayer, content);
Post a Comment for "Playing Youtube Video In Windows 8 App"