Question

I have made a C# Windows Forms Application in Visual Studio 2012 and added dlls from this webpage: http://vlcdotnet.codeplex.com/ I have already gotten video to work with this code:

VlcControl player = new VlcControl();
Vlc.DotNet.Core.Medias.MediaBase media = new 
    Vlc.DotNet.Core.Medias.PathMedia(@"path\movie.avi");
player.Media = media;
player.Play();

But that displays it in another window and I have no control over that. How would I embed the video in my form?

I have not found any documentation on how to do this programmatically. Most people in tutorials have some sort of vlc control listed in their toolbox, but I haven't, so I would need to do that with code.

I have tried using panel as VlcControl's parent:

player.Parent=panel1;

Movie still plays, but there is no video, only sound. What kind of container should I use and how to make it show the video?

More information: Here: VLC.DotNet Control Hosted in WPF it is said that it is possible to embed video inside WindowsFormsHost element in WPF. However, in Windows Forms Application, there is only ElementHost available to me. Could I use that to embed videos and if yes, how?

Was it helpful?

Solution

I have found the solution. I needed to add player to panel's controls and set the player size. Here it is, if anyone will ever need it:

player = new VlcControl();

panel1.Controls.Add(player);

player.BackColor = System.Drawing.Color.Black;
player.ImeMode = System.Windows.Forms.ImeMode.NoControl;
player.Location = new System.Drawing.Point(0, 0);
player.Name = "test";
player.Rate = 0.0F;

player.Size = new System.Drawing.Size(1024, 768);

Vlc.DotNet.Core.Medias.MediaBase media = new 
    Vlc.DotNet.Core.Medias.PathMedia(@"path\movie.avi");
player.Media = media;
player.Play();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top