Monday, October 20, 2014

VideoLan DotNet

In previous posts I already explained the inclusion of the VLC player in C# using the ActiveX controls. But these are more designed for webpages and now there exist .Net libraries to include the VLC player comfortably in C#. Therefore I here want to explain the inclusion of the library VideoLan DotNet.
First this has to be downloaded and unzipped. Then we have to add via Project - Add Reference the files "Vlc.DotNet.Core.dll" and "Vlc.DotNet.Forms.dll" (or depending on the application type ...Silverlight... or ...Wpf...) to the project. Then we are able to use the VLC control - not in the toolbox though, but we can add it codewise:

            VlcControl VLCPlayer = new VlcControl();

            this.Controls.Add(VLCPlayer);
            VLCPlayer.Location = new System.Drawing.Point(0, 0);
            VLCPlayer.Size = new System.Drawing.Size(this.Width, this.Height);
With this code we create a new control and add it to the controls on the form. Furthermore we set size and location of this.
With the following lines of codes we set the file to be played and play it:

Vlc.DotNet.Core.Medias.MediaBase Target = new Vlc.DotNet.Core.Medias.PathMedia(@"pathtofile");
VLCPlayer.Media = Target;
VLCPlayer.Play();

2 comments:

  1. Should we write thiscode to the main function of application.
    The one given in the link
    http://vlcdotnet.codeplex.com/wikipage?title=Forms

    ReplyDelete