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.