Click here to Skip to main content
15,867,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here's my code:
C#
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Vlc.DotNet.Forms;
using Vlc.DotNet.Core;
using Vlc.DotNet.Core.Medias;
using Vlc.DotNet.Core.Interops;

namespace vlcMediaPlayer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            VlcControl vlc = new VlcControl();
            Controls.Add(vlc);
            vlc.Location = new Point(100, 100);
            vlc.BackColor = Color.Red;
            vlc.Size = new Size(300, 300);
            MediaBase media = new PathMedia(@"D:\Parafait Home\Signage\Dhoni.mp4");
            vlc.Play(media);     //Here i am getting the exception
           
        }
    }
}


i have debugged it... But nothing seems wrong.. Please help me out here.. I am new..
Posted
Comments
H.Brydon 18-Sep-13 0:37am    
It seems to be complaining about vlc.dotnet.forms. Where did you initialize vlc.dotnet and likewise vlc.dotnet.forms? You need to show what VlcControl consists of.
Sachin Athrady 18-Sep-13 0:41am    
thx for ur reply sir.. I am new here.. I have downloaded those dll files and added them to reference.. then wrote this code.. Nothing else i did... Please guide me here
H.Brydon 18-Sep-13 1:14am    
Perhaps show the definition for the VlcControl class.

[going offline for about 12 hours shortly...]
Bernhard Hiller 18-Sep-13 3:12am    
Instead of starting to play in the Form_Load event, try a different approach: add a button on your form, and in the button click event do the playing of the mp4 file. I.e. put the lines
MediaBase media = new PathMedia(@"D:\Parafait Home\Signage\Dhoni.mp4");
vlc.Play(media);
into button1_Click. Perhaps it works, perhaps a different error appears, or no change at all...

1 solution

Hello.

The compiled files you can download from https://vlcdotnet.codeplex.com/[^] are buggy...

Download the sources https://vlcdotnet.codeplex.com/SourceControl/latest[^] recompile them and it works perfectly.

You will also find a sample winform application in the sources and you will notice that you need to initialise a vlc context.

C#
// Set libvlc.dll and libvlccore.dll directory path
VlcContext.LibVlcDllsPath = @"C:\Program Files (x86)\VideoLAN\VLC"; // CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
// Set the vlc plugins directory path
VlcContext.LibVlcPluginsPath = @"C:\Program Files (x86)\VideoLAN\VLC\pugins"; //CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
// Ignore the VLC configuration file
VlcContext.StartupOptions.IgnoreConfig = true;
// Enable file based logging
VlcContext.StartupOptions.LogOptions.LogInFile = true;
// Shows the VLC log console (in addition to the applications window)
VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
// Set the log level for the VLC instance
VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.None;
// Initialize the VlcContext
VlcContext.Initialize();


Valery.
 
Share this answer
 
Comments
Sachin Athrady 20-Sep-13 0:14am    
Thanks for your reply.. IT almost worked for me.. But when it reaches media ended state if I do vlcControl.stiop() my form gets hung... Annoying..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900