VLC in WPF. Tutorial?

This forum is about all development around libVLC.
EndLessMind
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2011 13:43

VLC in WPF. Tutorial?

Postby EndLessMind » 26 Feb 2011 13:55

Hello everyone!

I'm currently using MediaElement in my WPF project, but even with DivX codec installed i can't get subtitles.
I've read that VLC got a WPF control. But i don't know how to find it and how to get it in to my project.

Is there anyone that know a tutorial on this or can help me with it.
I'm currently using VLC 1.1.5

If i can't get help with that, can anyone help me with the subtitles(.srt files)?
How to read them in the right way so i can use a textblock to display the subtitles.


Thanks in advance.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: VLC in WPF. Tutorial?

Postby Jean-Baptiste Kempf » 27 Feb 2011 17:32

ARe you using libvlc.net?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

EndLessMind
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2011 13:43

Re: VLC in WPF. Tutorial?

Postby EndLessMind » 28 Feb 2011 01:28

No, currently i'm not using any VLC components.
Because i don't know how to or that to use.

So i would be grateful if anyone could help me.
I've searched i found something in some old VLC forum, but that forum was back in the "Version 0.8"-days.
So i figured that it would not help me, and anyway, i didn't understand how to use that one either.

And the standard MediaElement is just not doing it for me, because if the lack of support for subtitles.
I've tried to install different subtitle-decoders and video-decoders but it didn't help.
That's why i want to use VLC. Because VLC is the BEST media-player out there.

Hope you can help me.

Thanks in advance!

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: VLC in WPF. Tutorial?

Postby XilasZ » 01 Mar 2011 09:36

it's possible, yes.

To draw something, libvlc needs a handle, which doesn't exist in WPF.
A workaround is to use a WindowsFormsHost and put a winform panel inside it, and use the handle of this panel.

Note that in the same window, the WindowsFormsHost will always be drawn after all WPF components.

Another solution is to use vmem to get pixel data and display them yourself, but it's heavier to implement.

EndLessMind
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2011 13:43

Re: VLC in WPF. Tutorial?

Postby EndLessMind » 01 Mar 2011 16:19

Okey, so i've added the WindowsFormsHost and a winform panel inside.
What should i do now?
Add the libVLC.dll in references?

EndLessMind
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2011 13:43

Re: VLC in WPF. Tutorial?

Postby EndLessMind » 03 Mar 2011 20:46

You said the libvlc needs a handle.
How do i accomplish that?

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: VLC in WPF. Tutorial?

Postby XilasZ » 04 Mar 2011 15:04

Host.Child.Handle will give you the handle, use that when calling libvlc_media_player_set_hwnd.

you should take a look at existing components such as libvlc.net. It's open source, so you can see how it works.

You can also take a look at my own source : http://fritivi.git.sourceforge.net/git/ ... ivi;a=tree

EndLessMind
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2011 13:43

Re: VLC in WPF. Tutorial?

Postby EndLessMind » 04 Mar 2011 17:45

Thanks man :)

I've downloaded and built your project, so i could get the DLL.
But how do i add the VlcMediaPlayer to my panel in WindosFormsHost?
I tried:

Private Sub WindowsFormsHost1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles WindowsFormsHost1.Loaded
Dim pnl As New Windows.Forms.Panel
Dim VlcPlay As VlcMediaPlayer
pnl.Dock = Forms.DockStyle.Fill
pnl.Controls.Add(VlcPlay)
WindowsFormsHost1.Child = pnl
End Sub
But it gave me this error: " Value of type 'VideoLan.VlcMediaPlayer' cannot be converted to 'System.Windows.Forms.Control' "

I've tried to read your code to find out how you did, but can't seem to find it.

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: VLC in WPF. Tutorial?

Postby XilasZ » 08 Mar 2011 13:35

VlcMediaPlayer is not meant to be used like that, there is not vlc user control.

see PlayUrl in FritiviPlayer to see how i use play something.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests