playlist.stop() wont work... 1.1.7

This forum is about all development around libVLC.
tenesto
New Cone
New Cone
Posts: 5
Joined: 29 Mar 2011 17:48

playlist.stop() wont work... 1.1.7

Postby tenesto » 29 Mar 2011 17:56

hi!

i write an multimedia player with the libvlc 1.1.7, c# and visualstudio 2008.

i check for some playlistentrys and if there anyone then i check for isPlaying and if this happens, i start the method X.playlist.stop(), but it creates an error... i dont know the error, because the exception and vs dont create one.
i set the breakpoint to the functionstart, and with F10 (singlesteps) it will go through to the _vlcplugin.playlist.stop() line, but then it stucks... the program can only closed by push shift + F5 or with taskmanager...
the other part of the program works fine, example playlist.add, playitem, or something else...
if you need any other informations, just ask :)

the function with playlist.stop():

Code: Select all

private void playlistloeschen() { if (_vlcplugin.playlist.itemCount > 0) { if (_vlcplugin.playlist.isPlaying == true) { _vlcplugin.playlist.stop(); } _vlcplugin.playlist.items.clear(); _vlcplugin.playlist.clear(); } if (playbox2.Items.Count > 0) { playbox2.Items.Clear(); } _tempplayindex = -1; button_play.Image = Properties.Resources.button_play; _tpause = false; }
EDIT: here my eventhandler if the program is closing but it doesent help:

Code: Select all

private void zwemmp_FormClosing(object sender, FormClosingEventArgs e) { // playlistloeschen(); this._vlcplugin.Dispose(); }
p.s. whats the difference between playlist.items.clear() and playlist.clear()?

solud
Blank Cone
Blank Cone
Posts: 21
Joined: 15 Mar 2008 08:46

Re: playlist.stop() wont work... 1.1.7

Postby solud » 29 Mar 2011 23:03

There is a big thread on this problem already, which has a solution at the end:
LibVLC Deadlock on libvlc_media_player stop (win32) [Fixed]

The problem you're having with playlist.stop is caused by a call to libvlc_media_player stop from within the main program thread. Just create a new thread to call stop and you should be fine.

tenesto
New Cone
New Cone
Posts: 5
Joined: 29 Mar 2011 17:48

Re: playlist.stop() wont work... 1.1.7

Postby tenesto » 30 Mar 2011 13:50

cant handle the problem...

i write the function set_vlc_stop():

Code: Select all

private void set_vlc_stop() { try { _vlcplugin.playlist.stop(); //AxAXVLC.AxVLCPlugin2 tmp = new AxAXVLC.AxVLCPlugin2(); //tmp = _vlcplugin; //tmp.playlist.stop(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
and the call of the function is in the event if i press a "button" (picturebox with mouseclick)

Code: Select all

private void button_stop_Click(object sender, EventArgs e) { try { if (_vlcplugin.playlist.itemCount > 0) { //_vlcplugin.Dispose(); Thread t = new Thread(new ThreadStart(set_vlc_stop)); t.Start(); this.button_play.Image = Properties.Resources.button_play; _stop = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
the program throw no exeption message and the program stuck...

Rumpel
Blank Cone
Blank Cone
Posts: 16
Joined: 11 Feb 2011 08:18

Re: playlist.stop() wont work... 1.1.7

Postby Rumpel » 30 Mar 2011 15:13

I have no great experience with C#.

But in my case i start a thread call a function like you (set_vlc_stop) and then after i started the thread i call WaitForSingleObject(threadhandle, timeout)

tenesto
New Cone
New Cone
Posts: 5
Joined: 29 Mar 2011 17:48

Re: playlist.stop() wont work... 1.1.7

Postby tenesto » 30 Mar 2011 17:34

hmm... i think i wait for a answer of an other user.
if i use the waitforsingleobject function with kernel32.dll an error occurs with coredll.dll and if i include the coredll.dll an error with kernel32.dll pops up.

Code: Select all

//using is included //in class [DllImport("kernel32.dll", SetLastError=true)] static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds); //in function call WaitForSingleObject((IntPtr)t.ManagedThreadId, 2000);
the c# equivalent is System.Threading.ThreadPool.RegisterWaitForSingleObject(), but its currently to complex for my skills and i dont have the time (deadline for project) to read about it and learn.
i also used the BackroundWorker, but it doesnt help, same programstuck

in worst case, i will set the togglePause() and set the Time to zero... the stop() function would be nice but its only 0,0001 % from my project and i should use the time for other things, like the touchfunction of my mc, the bluetooth connection or something else... ;)

solud
Blank Cone
Blank Cone
Posts: 21
Joined: 15 Mar 2008 08:46

Re: playlist.stop() wont work... 1.1.7

Postby solud » 30 Mar 2011 17:51

You say you're using LibVLC 1.1.7, but you reference .playlist, which from what I can see is deprecated. Your object name is called vlcplugin -- are you using the ActiveX control?

If you're using LibVLC, you should be using LibVLC Media, LibVLC Media Player, LibVLC Media List Player.

Are you using a particular C# wrapper around LibVLC or did you write your own?

solud
Blank Cone
Blank Cone
Posts: 21
Joined: 15 Mar 2008 08:46

Re: playlist.stop() wont work... 1.1.7

Postby solud » 30 Mar 2011 18:04

I have no great experience with C#.

But in my case i start a thread call a function like you (set_vlc_stop) and then after i started the thread i call WaitForSingleObject(threadhandle, timeout)
Rumpel, from what understand of how you implemented the thread, it's possible your call to WaitForSingleObject(...) can possibly block for timeout-seconds if you call it from your main thread. Is your timeout variable set to 30s? That might explain the RTSP delay of 30s as you describe in the other thread. What you should do, instead of calling WaitForSingleObject(...), is call Thread::Join to wait for the thread to terminate (while also allowing window messages to be processed -- something WaitForSingleObject(...) does not allow).

tenesto
New Cone
New Cone
Posts: 5
Joined: 29 Mar 2011 17:48

Re: playlist.stop() wont work... 1.1.7

Postby tenesto » 30 Mar 2011 22:04

you are right solud, i use the activX, sry about the misstake but after so many ways to look for the right i choose the easy way. (because its a projekt with deadline ;) )
i registered the plugin with the windows console (start -> run-> cmd and then " regsvr32 "C:\Program Files (x86)\VideoLAN\VLC\axvlc.dll"")
then i add it to my project (com-element). like this:toolbox right-click -> add element -> COM and then VLCPlugin2 (i dont know the right way/names in english, because i use the german VisualStudio ;) ).
then i can choose the control like the normal dotNet controls (label, listbox,...)

is your solution only for the lib?
how can i look for more debugger informations? i only know the exeption.message or the breakpoint (with singlestep) way.
is there a way to see the threadhandling from the programm?

solud
Blank Cone
Blank Cone
Posts: 21
Joined: 15 Mar 2008 08:46

Re: playlist.stop() wont work... 1.1.7

Postby solud » 30 Mar 2011 22:59

I have essentially no experience with the ActiveX control -- I tried it once and found it didn't work for what I wanted.

LibVLC is easy to use -- follow the link to the thread I linked to you, and look for my post about a Sample Project I posted to illustrate the problem I was having. It doesn't contain the threading fix, but you already know how to do that so it should be easy to implement.

tenesto
New Cone
New Cone
Posts: 5
Joined: 29 Mar 2011 17:48

Re: playlist.stop() wont work... 1.1.7

Postby tenesto » 01 Apr 2011 09:55

sry, but i think im to stupid for this... i use now 3 ways to implement an vlc-player (basic functions: play, stop and open). i also tried a finish projekt from Helyar but in every case, vlc crash at the initial point... i give up... i hate it to give up, but i have no time to test more... i use the stupid way and set pause an also the time to zero :(

thanks for your help


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests