Playing Youtube videos in Silverlight 5 using VLC Media Player
In this article we would see, how we could leverage the support of VLC control for playing “Youtube” videos.
- You need Silverlight 5 SDK installed, as VLC controls are available for Silverlight 5 support.
- VLC player installed. (Version 1.2 onwards)
We would create a sample Silverlight 5 project.
Remember that we need to have Out-Of-Browser enabled. (currently it supports OOB to access VLC COM).
We would also need MVVMLight libraries for our MVVM pattern.
We would have property that would give us a collection of videos.
The youtube class goes like this.
The trick for getting the youtube video image is as follows:
Now we would initialize the VlcContext in ViewModel constructor:
Also we would open up the Open File Dialog to open the “libvlc.dll”. This is a primary dll required to continue further.
Also we have to put a try catch for adding the details to VlcContext, otherwise each time it would fail saying: “the dll is already added”.
Now we would go the view.
We would have control in place for Vlc Control. When you add the following namespace.
We would have a listbox for displaying our videos.
Also we need use the VlcControl as following. (Till now this is the only way)
As you see above, the ImageBrush of the Grid is required to give you the pictures used by the VLC com.
Now on the selection changed we would have the url and we would play the video.
Now let’s run the application.
Yes, we would add the DLL at first.
Then we can see the Video List is being populated.
And finally we would select a video. After a short delay the video started playing. (Have patience)
Source Code: Click Here
Article as PDF: Click Here
VLC DotNet: Click Here