Recently, I was working on a C# Windows 8 application that was required to play Youtube videos as one of the features. At first I wasn’t sure if there was a simple way to accomplish the task, but with a little research I found a very nice solution.
First I created a very simple WebView in my *.xaml page:
You’ll notice I haven’t specified any dimensions or any other attributes other than a name. I’ll use the name in my *.xaml.cs file to reference the WebView instance.
Now in my *.xaml.cs file, I simply set the contents of the WebView to an iframe that contains the embedded youtube video. The size of the iframe will define the size of my WebView:
videoID is a string containing the ID of the video you want. It’s the string that comes after the v= and before the & in the video URL:
The result is a youtube video embedded in your application with the familiar controls: