Media Player Classic libraries in my Windows Form project

2

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

    
asked by anonymous 11.03.2014 / 21:26

3 answers

5

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

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

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

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

  • Add COM component (axvlc.dll) to the registry using regsvr32. To do this, type regsvr32 "InstallationLog \ axvlc.dll" at 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 check 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 / play and stop simply use the following commands:

axVLCPlugin21.playlist.play();

axVLCPlugin21.playlist.togglePause();

axVLCPlugin21.playlist.stop();
    
11.03.2014 / 21:48
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 (especially the last one I'm tending to tell you is the best) work in 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 1080p media in stretch for more than one monitor, it starts to cause stuttering.

Underneath the wipes it creates a Windows Media ActiveX and decides between DirectShow and Media Foundation. In the case of no codec installed, in windows 7 and 8, it will use the native codec windows (Microsoft DTV-DVD Video Decoder).

WPF MediaKit

This is an opensource library that, underneath the cloths, also uses DirectShow and Media Foundation. It has an element that replaces the WPF MediaElement.

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

AxWindowsMediaPlayer

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

DirectShow + MediaFoundation

That, to me, is the best solution. You can use the DirectShow.Net libraries and MediaFoundation.Net libraries.

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 filter chart used to render a video.

At the end of the day, everything depends on how much your hardware can handle and which codecs you will 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 demultiplexer for you to use, so you would have to at least register a demux. If you go that way, take a look at GDCL's mp4demux.

(Sorry for not linking to you, but I do not have enough reputation for this)

    
18.03.2014 / 19:48
2

I do not think you have a simple way to do this in Windows Forms, I suggest you use WPF because it already has components made specifically for this and they are very simple to work with, as well as how 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. (do not be scared with xaml, the creation interface is very visual) link

    
14.03.2014 / 21:32