VideoLan.Interop a .Net libvlc 0.9.x wrapper

This forum is about all development around libVLC.
Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 12 Jul 2009 11:48

I've been using VideoLAN.Interop.dll for quite some time now and I like it, but I just can't get it to work with 1.0.0.

The last thing I tried was to use the code drop from meedios' repository, because it contains a version specifically for 1.0.0. The code was updated 2 days ago, but still crashes on my computer. I tried the "VlcMediaPlayer.Sample" player, but that one doesn't work either (btw, you need to change the project configuration to "x86" from "Any CPU" to make it work on 64bit computers).

I'd love to use the new features of 1.0.0, can anyone help me? Or is simply not working yet?

Edit: Ok, nevermind. I found out why it's not working. The "lua" subdirectory is now also required to be inside my apps execuable directly. Previously, only the "plugins" directory was neccessary.

Edit 2: Well, not really. It's still not working on my own app correctly. The "vmem" module seems to be broken, but even without that, I can only use it reliably once out of ten times or so. The other times it just goes into an endless loop. Hm.

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 14 Jul 2009 01:50

I'm still working on the 1.0.0 version of this library. I've only ported some of the new functions and tested nothing. I stopped working on it a couple days ago because the the sample app would crash just like you mentioned and I did not have the time to diagnose the problem. So now that I know its the lua directory, I'll get back to working on it again.

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 15 Jul 2009 18:18

I see the crashing problem now. Every video I play crashes after a few seconds. I'll have to implement VLC's log so I can see what is crashing windows.

Beardless2
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 02 Feb 2007 09:53

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Beardless2 » 16 Jul 2009 13:13

can you guys get it to work with officail v1.0.0? i have problems with it but the nightly builds are fine?

Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 18 Jul 2009 13:08

I just wrote a simple 100% native player using one of the tutorials in the wiki and even that one crashes after the first frame. Can anyone confirm that libvlc is actually working right now? I'm using Windows 7 64bit, but I also tried this in a virtual machine with Windows XP 32 with the same result. The normal VLC player works fine.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 18 Jul 2009 15:40

A few month ago, I made a player to watch tv from my internet provider, but it can also be used to watch any stream or file. It's full WPF (.Net 3.5), use libvlc through kairos' wrapper.
I updated it to reflect changes between libvlc 0.9 and 1.0. Everything i use is working fine. It works on XP, Vista, and Win7 without issues.

Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 18 Jul 2009 19:57

A few month ago, I made a player to watch tv from my internet provider, but it can also be used to watch any stream or file. It's full WPF (.Net 3.5), use libvlc through kairos' wrapper.
I updated it to reflect changes between libvlc 0.9 and 1.0. Everything i use is working fine. It works on XP, Vista, and Win7 without issues.
Strange. For me, it doesn't work at all. Which version of 1.0 are you using?

Some testing has revealed that I can play OGG and WAV files just fine, while MP3s and videos crash. When the debugger is attached I can see, that all plugins get loaded, so the plugin directory should be set correctly.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 19 Jul 2009 11:09

I use the official release. But it also worked with 1.0.0 rc3 and rc4 (after modifying the wrapper to reflect changes in libvlc).

Maybe it's just that the tutorials that you used are outdated.

Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 19 Jul 2009 13:14

I use the official release. But it also worked with 1.0.0 rc3 and rc4 (after modifying the wrapper to reflect changes in libvlc).

Maybe it's just that the tutorials that you used are outdated.
That's possible, when you play an MP3 what initialization steps do you do?

Mine are the following:

client options:
"-I", "dummy",
"--ignore-config",
"--plugin-path=[...]"

- libvlc_new
- libvlc_media_new
- libvlc_media_player_new_from_media
- libvlc_media_player_play
- Sleep(15000) // just for testing
- libvlc_media_player_stop
- libvlc_media_player_release
- libvlc_release

The crash happens in the Sleep, but that's probably just a threading issue.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 19 Jul 2009 21:01

try to remove "--plugin-path", i noticed that since 1.0, libvlc crash with that option. just let the plugin folder with libvlc (the same way they are in vlc).

Anyway, here the steps when i use with libvlc, and the main options. I think there's nothing wrong in your steps, it should work. mine is different because the media player is created only once, and medias are created and attached to it when changing channels.

Main options :
"--no-one-instance"
"--no-loop"
"--no-drop-late-frames"
"--disable-screensaver"
"--no-video-title-show"
"--overlay"
"--vout=directx"

libvlc_new
libvlc_media_player_new
libvlc_media_player_set_hwnd
libvlc_media_new
libvlc_media_player_set_media
libvlc_media_release
libvlc_media_player_play
...
libvlc_media_player_stop
libvlc_media_player_release
libvlc_release

lopez.tuparles
New Cone
New Cone
Posts: 6
Joined: 21 Dec 2008 20:25

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby lopez.tuparles » 20 Jul 2009 15:10

Hi,
As i undestand Vlc APi can't read playlist Stream. Is there a way to extract a list of Stream from a playlist with the API.
Thanks in advance.

if I pass the actual stream URL, the stream plays. ie the following works:
Code: Select all
string filename = "mms://wmlive-acl.bbc.co.uk/wms/bbc_ami/radio1/radio1_bb_live_eq1_sl0?BBC-UID=945a3082dec341e5dda25cfd113eaa3e1c94c2be00d0e1f4a42fa936cf8ec007&SSO2-UID="
but if I pass a playlist file the stream doesn't play. The same is true for winamp m3u files.
Code: Select all
string filename=http://www.bbc.co.uk/radio1/wm_asx/aod/radio1.asx
Both links play in a normal VLC instance.
What do I need to prepare the stream for playback?
Cheers
have anyone manage to solve this problem yet? I like this wrapper alot and it also works on 1.0.0
The only thing thatis bugging me is the inability to play online playlist

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 20 Jul 2009 15:51

Hi,
As i undestand Vlc APi can't read playlist Stream. Is there a way to extract a list of Stream from a playlist with the API.
Thanks in advance.
i don't use them, but maybe the functions named libvlc_media_list_* can do it. Try the VlcMediaList class, maybe it works (i didn't try them)

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 21 Jul 2009 03:54

try to remove "--plugin-path", i noticed that since 1.0, libvlc crash with that option. just let the plugin folder with libvlc (the same way they are in vlc)
I was having the same problem where vlc would crash in the first few seconds of playing any file. Although I don't understand why, removing the plugin-path worked for me.

tamiro44
Cone that earned his stripes
Cone that earned his stripes
Posts: 131
Joined: 15 Feb 2009 15:21

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby tamiro44 » 21 Jul 2009 07:58

Hi,
How can you force your player to adjust the movie resolution?
After the player handle passed to the form, it won't change automatically.
Can i find out from API the movie's resolution?

Tamir.

Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 21 Jul 2009 14:43

try to remove "--plugin-path", i noticed that since 1.0, libvlc crash with that option. just let the plugin folder with libvlc (the same way they are in vlc)
I was having the same problem where vlc would crash in the first few seconds of playing any file. Although I don't understand why, removing the plugin-path worked for me.
I'll try it this evening.

Edit: Jup, that's it. No more crashes.
Thanks Xilas!

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 22 Jul 2009 08:35

Just a warning, I've started adding in the new 1.0.0 functionality into this wrapper. So if your going to use the 1.0.0 branch on my svn then just be aware its still in development.

shultas
New Cone
New Cone
Posts: 1
Joined: 24 Jul 2009 17:37

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby shultas » 24 Jul 2009 23:57

Hi There-

First off, awesome job on this wrapper! I spent days trying to figure out how to play a MPEG-4 file (I'm a newb, I suck at this point), but about 10 minutes getting it to work with your library, so thank you!

I have a question. I have adapted it to work with two video windows side by side for an application I am trying to write. Basically lets the user load two files and play them back at the same time so they can analyze them side by side. It works pretty good for the most part. On occasion if I call things such as "VlcPlayer.WillPlay" (if a video is loaded or not loaded) it will crash the app and tell me something about it couldn't read protected memory. Those little kinks I can work out, but there is one thing I just cannot figure out.

I have two instances of the VideoLanClient and VlcMediaPlayer, one for each Panel/Video Window. The Player.Mute = true, and = false does not work properly all the time for me. I have two buttons on my form, all they do is "VlcPlayerLeftWindow.Audio.Mute = !VlcPlayerLeftWindow.Audio.Mute". I press play, the videos begin to play, and I press the mute button. Sometimes it works, sometimes it does not. I've found that if you click like a mad man in different combinations, it will get it to start working again. The other issue that I am having ... I only want audio from the first VlcPlayer to be heard. I have a Play button. On the play button it calls VlcPlayerLeftWindow.Play(); then VlcPlayerRightWindow.Play(); If I set VlcPlayerRightWindow.Audio.Mute = true in this code event, the audio mutes for both players. However, if I put a Thread.Sleep(1000) in there, causing the program to wait for a second after the video starts playing, and then call Mute, it will mute only that one channel (most of the time). I cannot figure out what I am doing wrong, any help would be appreciated.

Here's what I've done:

VlcLeftWindow = new VideoLanClient();
VlcRightWindow = new VideoLanClient();
VlcPlayerLeftWindow = VlcLeftWindow.NewMediaPlayer(panelVideoLeftWindow.Handle);
VlcPlayerRightWindow = VlcRightWindow.NewMediaPlayer(panelVideoRightWindow.Handle);

-- Load Click Code, Left Window--
if (OpenFile.ShowDialog() == DialogResult.OK)
{
VlcMedia desc = VlcLeftWindow.NewMedia(OpenFile.FileName);
VlcPlayerLeftWindow.Load(desc);
desc.Dispose();
}

-- Load Click Code, Right Window--
if (OpenFile.ShowDialog() == DialogResult.OK)
{
VlcMedia desc = VlcRightWindow.NewMedia(OpenFile.FileName);
VlcPlayerRightWindow.Load(desc);
desc.Dispose();
}


-- Play Click Code ---
// if ( (VlcPlayerLeftWindow.WillPlay) && (VlcPlayerRightWindow.WillPlay)) // Took this line out, because it crashes the program when a file is not loaded.

VlcPlayerLeftWindow.Play();
VlcPlayerRightWindow.Play();
VlcPlayerRightWindow.Audio.Mute = true; // This causes audio from VlcPlayerLeftWindow AND VlcPlayerRightWindow to mute
// Thread.Sleep(1000);
// VlcPlayerRightWindow.Audio.Mute = true; // This sometimes works and will only mute the right window's associated audio

-- Mute Click Code, Left --
VlcPlayerLeftWindow.Audio.Mute = !VlcPlayerLeftWindow.Audio.Mute; // Sometimes works, sometimes it doesn't

--Mute Click Code, Right --
VlcPlayerRightWindow.Audio.Mute = !VlcPlayerRightWindow.Audio.Mute; // Sometimes works, sometimes it doesn't

EDIT: I also tried all of this by using only one VideoLanClient and still cannot get the audio to mute and unmute reliably.

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 26 Jul 2009 19:39

Wow, a lot of problems. Your first problem is something I find out only after creating VideoLan.Interop, you can only create a single VideoLanClient object. Essentially the second object overwirites the first object and is the cause of the unexpected results. This could be the cause of many of the other problems like reading protected memory. To use multiple players, create a single VideoLanClient, and use that same object to create 2 VlcMediaPlayers.

Your second problem stems from the first problem. If you look at my code I sometimes call methods with p_media_player (pointer to a media player object) and other times p_instance (pointer to the vlc instance). When a method uses p_media_player, that method is specific to the media player you call it from. When a method uses p_instance then that method is global among all media player instances. Mute is one of those methods that uses p_instance, so it should mute all media players. Calling it twice like in your code should actually mute it first, then unmute it the second time.

ekennedy
Blank Cone
Blank Cone
Posts: 38
Joined: 18 Sep 2008 22:05
VLC version: 1.0
Operating System: Windows
Location: Texas

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby ekennedy » 28 Jul 2009 16:00

I just wrote a simple 100% native player using one of the tutorials in the wiki and even that one crashes after the first frame. Can anyone confirm that libvlc is actually working right now? I'm using Windows 7 64bit, but I also tried this in a virtual machine with Windows XP 32 with the same result. The normal VLC player works fine.
I built a wrapper using MFC (I can here the howling already!) and it's not crashing on WinXP or Vista 64-bit. I haven't tried Win7 yet. I'm planning on posting a sample somewhere soon.

I created a lib file from libvlc.dll then created a wrapper.

ed

Mongrel
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Jul 2009 11:35

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Mongrel » 28 Jul 2009 17:11

I just wrote a simple 100% native player using one of the tutorials in the wiki and even that one crashes after the first frame. Can anyone confirm that libvlc is actually working right now? I'm using Windows 7 64bit, but I also tried this in a virtual machine with Windows XP 32 with the same result. The normal VLC player works fine.
I built a wrapper using MFC (I can here the howling already!) and it's not crashing on WinXP or Vista 64-bit. I haven't tried Win7 yet. I'm planning on posting a sample somewhere soon.

I created a lib file from libvlc.dll then created a wrapper.

ed
The issue with the crashes has been resolved already. Adding the "plugin-path" option to libvlc makes it really unstable. Removing it is the way to go.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 29 Jul 2009 17:04

Kairos, did you managed to get event data correctly (position in a PositionChangedEvent) with 1.0.x ?
It worked with libvlc 0.9, but with 1.0.x, i got bad values (currently, i got something like 2E-44, almost 0).
I modified event class according to changes in libvlc (i looked to changes in vlc's git reposititory).
With or without those changes, nothing works.

By the way, your last commit message says : "Finished implementing tracks, though not all work due to bugs in libvlc". What part exactly ? i'm using tracks for audio/video/subtitles, and everything is working fine.

PS: i'm using your wrapper 0.9, that i upgraded myself to 1.0 before you, maybe i did something wrong

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 29 Jul 2009 21:53

Kairos, did you managed to get event data correctly (position in a PositionChangedEvent) with 1.0.x ?
It worked with libvlc 0.9, but with 1.0.x, i got bad values (currently, i got something like 2E-44, almost 0).
I modified event class according to changes in libvlc (i looked to changes in vlc's git reposititory).
With or without those changes, nothing works.
I didn't know the events were broken. I'll look at it when I get a chance.
By the way, your last commit message says : "Finished implementing tracks, though not all work due to bugs in libvlc". What part exactly ? i'm using tracks for audio/video/subtitles, and everything is working fine.
You could always change tracks, but now you can get the description for each track. For this reason I revamped how tracks are handled and gave each track (subtitle, title, chapter, audio, and video) a separate class to wrap track specific functions. I still need to iron out my own bugs like when to load descriptions, but the problem in vlc I was referring to was here viewtopic.php?f=32&t=62686. Also when testing the subtitle tracks, I noticed every video with a subtitle I tested would crash on loading. I've only tried 1.0.0 release. It may have been fixed I don't know.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 29 Jul 2009 22:06

Hmm ok. now i remember, i noticed that get/set are strange, see here : viewtopic.php?f=33&t=60943#p203685 , last post (don't bother with deinterlace or the issue at the end, i wasn't doing thing right).

some works with the index in the track list, the others works with the real id.

my modified wrapper take those strange things into account. But i did this before the official release with 1.0 rc4. now with 1.0.1, i should test again, maybe it's fixed.

Edit: i just tested, video_get_track give an index, while video_set_track need the real id. nothing seems to be changed in 1.0.1
Also when testing the subtitle tracks, I noticed every video with a subtitle I tested would crash on loading. I've only tried 1.0.0 release. It may have been fixed I don't know.
An avi with an srt subtitle file works perfectly for me, i can switch all tracks (audio/video/subtitle) on/off without issue (thanks to my wrapper which use it the id or the index, depending on the function to call). But i noticed that vlc crashes if it's an ass subtitle file.

nisha
New Cone
New Cone
Posts: 1
Joined: 31 Jul 2009 11:09

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby nisha » 31 Jul 2009 11:15

Is VLM working in latest interop 1.0.0 wrapper. How can i use it to broadcast more then 1 stream.

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

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby XilasZ » 05 Aug 2009 14:09

Hi, kairos, there is a small bug in the wrapper when using libvlc_media_get_meta.

It seems that libvlc returns an ansi string, while .NET is trying to map the return value as a unicode string, so it crash (memory protected error).
To fix this, just add "[return:MarshalAs(UnmanagedType.AnsiBStr)]" before the function declaration.

Code: Select all

[return:MarshalAs(UnmanagedType.AnsiBStr)] internal static extern String libvlc_media_get_meta(.....);
By the way, i may have fixed my random crash issue after reading this : viewtopic.php?f=32&t=62504&start=0&hilit=delphi
When calling stop or exiting the program, it seems libvlc can crash if libvlc is still linked to a display surface.
I was setting the surface only once at startup, and i never broke the link to libvlc. I think that's the cause of my random crashes at exit or when calling stop.
Now i set the display surface when starting playing something, and remove it as soon as it stops. Since i did that, i got 0 crash.

I also tried to use the mediametachanged events, but nothing works. as soon as the event is fired, i got a memory protected error, i guess there is something wrong between libvlc and .net, probably a type mismatch. did you manage to make events work with 1.0.x ?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests