Program freezes when calling stop in MediaPlayerEndReached

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
mario123
New Cone
New Cone
Posts: 9
Joined: 08 Mar 2011 16:21

Program freezes when calling stop in MediaPlayerEndReached

Postby mario123 » 09 Mar 2011 09:32

I have a C# program with a VLC activeX on a form. If a call the playlist.stop function in de MediaPlayerEndReached event handler, my program freezes.

I am using VLC activeX v1.1.7

Code: Select all

private void axVLCPlugin21_MediaPlayerEndReached(object sender, EventArgs e) { this.axVLCPlugin21.playlist.stop(); }
I also tried the same thing using Builder. So, a Builder form with a VLC activeX on it. I also called the playlist.stop in the MediaPlayerEndReached. Again my program freezes.

Code: Select all

void __fastcall TfrmEventViewer::VLCPlugin21MediaPlayerEndReached(TObject *Sender) { VLCPlugin21->playlist->stop(); VLCPlugin21->playlist->clear(); }
Does anybody have an idea why this is happening?

Dandy
New Cone
New Cone
Posts: 2
Joined: 08 Mar 2011 20:36

Re: Program freezes when calling stop in MediaPlayerEndReach

Postby Dandy » 10 Mar 2011 15:00

Infinite recursion?
Maybe playlist.stop() triggers MediaPlayerEndReached event?
If the video reaches the end, doesn't it stop automatically?

mario123
New Cone
New Cone
Posts: 9
Joined: 08 Mar 2011 16:21

Re: Program freezes when calling stop in MediaPlayerEndReach

Postby mario123 » 11 Mar 2011 08:20

Yes, if the video reaches the end, it stops automatically. But you can still see the last image of the video and I would like to remove that. So I would like to call the stop function to clean up.
I don 't think it's infinite recursion because I have a breakpoint in my debugger at the beginning of the MediaPlayerEndReached event. It doesn't hit that breakpoint a second time.
I also tried posting a windows message to myself and calling the stop function in the event handler. So now I have something like this:

Code: Select all

void __fastcall TfrmEventViewer::VLCPlugin21MediaPlayerEndReached(TObject *Sender) { //VLCPlugin21->playlist->stop(); PostMessage(this->Handle,WM_PLAYLIST_STOP,0,0); } void __fastcall TfrmEventViewer::WMPlaylistStop(TMessage& message) { VLCPlugin21->playlist->stop(); }
But this doesn't solve anything. My program reaches the WMPlaylistStop() function but again my program freezes when I call the stop function.

I also looked up the vlc stop function. It looks like this:

Code: Select all

void libvlc_media_player_stop( libvlc_media_player_t *p_mi ) { libvlc_state_t state = libvlc_media_player_get_state( p_mi ); lock_input(p_mi); release_input_thread( p_mi, true ); /* This will stop the input thread */ /* Force to go to stopped state, in case we were in Ended, or Error * state. */ if( state != libvlc_Stopped ) { set_state( p_mi, libvlc_Stopped, false ); /* Construct and send the event */ libvlc_event_t event; event.type = libvlc_MediaPlayerStopped; libvlc_event_send( p_mi->p_event_manager, &event ); } if( p_mi->input.p_resource != NULL ) input_resource_TerminateVout( p_mi->input.p_resource ); unlock_input(p_mi); }
Probably the lock_input() or the release_input_thread() function causes the problem.

jack.ting
Blank Cone
Blank Cone
Posts: 35
Joined: 19 Jan 2011 04:04

Re: Program freezes when calling stop in MediaPlayerEndReach

Postby jack.ting » 14 Mar 2011 07:04

Hey,
I've the same trouble experience on javascript programming.

Here's what I found and my suggestion:
1. there's no need to call "playlist->stop()" at all, it will stop automaticlly (no matter it's the last item of the playlist or not).
2. It seems that the "MediaPlayerEndReached" is designed for trigger of playing next item in the playlist (for looping control or for randomize control or ...).
3. If you want to do something else like "playlist->clear()", you have to wait until the "stoped" state is reached.

so, in javascript:
1. I register the "MediaPlayerEndReached" event to a check the state is "ended" or not, if yes play next item (for looping), otherwise do nothing.
2. and call setTimeout() or setInterval() to wait several ms then checking the state of VLC instance, to make sure the "stoped" state is reached before I processing the next command.

mario123
New Cone
New Cone
Posts: 9
Joined: 08 Mar 2011 16:21

Re: Program freezes when calling stop in MediaPlayerEndReach

Postby mario123 » 14 Mar 2011 14:27

Hi,

Thanks for you suggestion. I am not using javascript, so I don't have setTimeout() or setInverval(). But I can create a timer, using a callback function. So I tried that. In my callback function I first verify the state and if it is in the ENDED state, I call the playlist->stop() function. I know, the stop function is not needed here, but I just wanted to test that it did not freeze my program. And indeed, it works!

Now I got curious, what would happen if I do the same thing in the "MediaPlayerEndReached"? So now, I only call playlist->stop() in the ENDED state. Now, my program freezes again.

So, the solution with the timer works, but it probably has nothing to do with the ENDED state.

I know, I don't really need the playlist->stop(), but I do would like to know in which cases it can be used and when not.

jack.ting
Blank Cone
Blank Cone
Posts: 35
Joined: 19 Jan 2011 04:04

Re: Program freezes when calling stop in MediaPlayerEndReach

Postby jack.ting » 16 Mar 2011 06:32

Sorry, that's my question, too.

I'm trying to digging more information the source code.
But currently, I'm focus on something else, I just could spend few time on it.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 4 guests