YouTube Video player

Posted Date:     Total Responses: 0    Posted By: Nikhil Gaur   Member Level: Gold   Points/Cash: 6   

In main window you can search videos according to you proffered keyword.

You are free to drag the YouTube feed items around, providing you are currently in Drag mode. Where the Mode is changable using the right click context menu.

When you toggle out of Drag mode, you will be in Play mode, so will no longer be able to move the video items around. Instead when you move the mouse over an video item you will see a PLAY icon appear.

When you then click this PLAY icon a new video viewer will be shown where you can view the YouTube video. This window is animated into/out of view. You should be able to open the viewer window whenever you are in Play mode and click on a unique video item.

it is actually just a bit of XLINQ, as follows

var xraw = XElement.Load(string.Format(SEARCH,keyWord));
var xroot = XElement.Parse(xraw.ToString());
var links = (from item in xroot.Element("channel").Descendants("item")
select new YouTubeInfo
LinkUrl = item.Element("link").Value,
EmbedUrl = GetEmbedUrlFromLink(item.Element("link").Value),
ThumnailUrl =
child => child.Name.ToString().Contains("thumbnail")


return links.ToList();

So this is used within the YouViewerMainWindow to create a bunch of YouTubeResultControl controls, which are then added to a DragCanvas. I can take no credit for the DragCanvas, I stole that straight from Josh Smith, using this code

There is nothing special to say about the YouTubeResultControl controls, they are fairly simply controls, that simply contain a single YouTubeInfo item which is used within an event that is raised when the user clicks the internal YouTubeResultControl controls play button. The YouViewerMainWindow uses the YouTubeInfo item to pass to the Viewer control, which in turn is resposible for playing the actual video.

So far nothing special right, all very easy stuff.

The only part that's a bit interesting is that we can play the YouTube video in the new WebBrowser control. This is neat.

Normally WPF only lets you play Windows Media Player supported files that are local or MMS prefixed streams.

YouTube is neither of these, so how does it work. Well luckily the RSS feed contains enough information for us to do some string manipulation to get a new Url, that points to something much more interesting.

Basically from the RSS feed we can get the following string

but if we mess around with it a bit we can get

Which is a link to a SWF (Flash) file, that will play directly in the new browser if you past this in to a browser address bar. Aha.

So we can use this new Url and use that as the Source property for the new .NET 3.5 SP1 WebBrowser control, and we get the usual YouTube player we are used to, for free. Neato. I also tried this with the .NET 2.0 WinForms WebBrowser (interop so WindowsIntegration Dll required) control, and the WPF Frame control but they didn't work like the new .NET 3.5 SP1 WebBrowser control.


  • YouTube Video player (

  • Project Feedbacks

    Author: Member Level: GoldRevenue Score: 1 out of 5
    hi really super man you rock it

    but one small doubt how can i play videos it is not playing

    Author: Member Level: GoldRevenue Score: 2 out of 52 out of 5
    Its really nice. I would like learn such type of things.

    It will be greatful for me to send the files.

    Siva Sreenath

    Author: Member Level: GoldRevenue Score: 1 out of 5
    nice post dude............

    Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
    hi friend
    I have to make web application on the video & image gallery in
    So can u help me???

    Author: Member Level: GoldRevenue Score: 2 out of 52 out of 5
    just right click on video and select play mode.

    and to again come back to drag mode right again and select drag mode.

    Post Feedback
    You must Sign In to post a feedback.
    Next Project: Art Gallery C# project
    Previous Project: Subtext to Wordpress Converter

    Return to Project Index

    Post New Project

    Related Projects

    Top Contributors
      Last 7 Daysmore...

      Awards & Gifts

      Online Members

      Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India