Media Player Classic libraries in my Windows Form project

Asked

Viewed 2,384 times

2

I am developing an application that will work as a player, however the videos inserted in my software will be of various different formats avi, mp4, flv and etc... for this reason I do not want to use windows media player, would like something more complete as classic media player, are there libraries of it? or similar?

3 answers

5


You could use a Ffmpeg Wrapper to convert videos to some format supported by Windows Media Player at your discretion or try something with Vlcdotnet, since it also works together with Ffmpeg.

In my view, another very interesting solution would be embed VLC Media Player to your project:

  • You can download version 1.1.9 of VLC (vlc-1.1.9-Win32. exe) here.

    Note: I recommend the use of the above version because later versions presented some errors of incompatibility with projects . NET, resulting in failure to create the 'Axhost' component and itself System.Runtime.InteropServices.COMException.

  • Add COM Component (axvlc.dll) to the record using regsvr32. To do this, type regsvr32 "Camiodeinstalacao axvlc.dll" in the command prompt, as in the example:

    regsvr32 "C:\Program Files\VideoLAN\VLC\axvlc.dll"

  • Right-click on your Toolbox and click on "Choose Items". Go to the "COM Components" tab and tick the VLC Activex Plugin v2.

  • Add the component to your form.

Now, to choose a video and add it to the playlist you can use the Openfiledialog:

OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "AVI (*.avi)|*.avi|MP4|*.mp4"; //Definindo o filtro (extensões dos vídeos pelos quais o OpenFileDialog buscará).

if (ofd.ShowDialog() == DialogResult.OK) //Teste para verificar se o arquivo foi selecionado.
{
    axVLCPlugin21.playlist.add(ofd.FileName, ofd.SafeFileName, null); //Adicionando vídeo à playlist.
    //Obs: a propriedade SafeFileName retornará o nome e a extensão do arquivo em questão.
}

To play, pause/reproduce and stop just use the following commands:

axVLCPlugin21.playlist.play();

axVLCPlugin21.playlist.togglePause();

axVLCPlugin21.playlist.stop();
  • https://www.nuget.org/packages/Vlc.DotNet/ ?

  • Hello @Guilherme Thank you for your reply. I did exactly how you indicated in your reply but when I run my form appears several error messages saying that I could not find the dll’s of the plugin folder http://imageshack.com/a/img823/2790/39wq.jpg

  • This liba52tofloat32_plugin.dll appears in your plugins folder?

  • Yes it appears, it shows this messages to all dll’s of the plugin folder. my machine is x64 WP project is running as x64 and VLC is x86, will that be problem ?

  • I believe this is the problem. Try downloading a dll to x64 or accessing the properties of your project (Build tab) to change the platform.

  • That’s right I selected the option "Any CPU" and it worked I will do the tests for now thank you very much.

  • @Guilherme Activex control worked perfectly I am able to play videos and etc. however I need to get data as the duration of the video and the position, but the events of Axvlcplugin2 does not seem to work. posted this question thank you if you can help me. http://answall.com/questions/9576/activex-axvlcplugin2-evento-works

  • I added an answer to the question, I hope I’ve helped (:

Show 3 more comments

3

Tuyoshi,

I have in mind now some alternatives for you. The first two (Mediaelement and WPF Mediakit) are specific to WPF. The last two (mostly the last one I’m tending to tell you is the best) work on Windows Forms as well.

Mediaelement

If you are considering using WPF and the native component (Mediaelement) to play media, keep in mind that it works very well if you are going to play only one media. With more than one media playing, or a 1080p stretch media for more than one monitor, it starts to cause stuttering.

Underneath the scenes he creates an Activex from Windows Media and decides between Directshow and Media Foundation. In case of no codec installed, in windows 7 and 8, it will use the windows native codec (Microsoft DTV-DVD Video Decoder).

WPF Mediakit

This is an opensource library that, underneath the scenes, also uses Directshow and Media Foundation. It has an element that replaces the Mediaelement of WPF.

It seems to have a slightly faster implementation and brings a good performance with two monitors and 1080p videos. With three monitors playing three 1080p videos, you get a bit of stuttering depending on your hardware/system configuration.

Axwindowsmediaplayer

Windows Media Player can be instantiated via Activex and used within the application (it works in Windows Forms as well). With three monitors, I noticed a lot of loss of keyframes and it was certainly the worst option.

Directshow + Mediafoundation

This, for me, is the best solution. You can use the Directshow.Net libraries and Mediafoundation.Net.

They allow you to specifically point out which codec you want to use. If you want to get a sense of how to build your application on top of them, take a look at Graphedit or Graphstudio, which is software that mounts the graph of filters used to render a video.

At the end of the day, it all depends on how much your hardware holds and which codecs you’ll have installed. Remembering that windows already comes with a Decoder of some types, playing many mp4, avi and mpg out-of-the-box, but does not provide a demultiplexor for you to use, so you would have to at least register a demux. If you go this way, take a look at the GDCL mp4demux.

(Sorry I didn’t put the links to you, but I don’t have enough reputation for it)

2

I don’t think there is a simple way to do this in Windows Forms, I suggest you use WPF, because it already has components specifically made for this and that are very simple to work with, also as you have experience with Windows Forms should get used to it quickly.

Here is a tutorial on how to create a music and video player with wpf. (don’t be alarmed by the xaml, the creation interface is very visual) http://www.wpf-tutorial.com/audio-video/how-to-creating-a-complete-audio-video-player/

  • Rodrigo Santos my biggest problem has been the various media formats, in relation to codecs as a WPF application would help me?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.