VLC Activex V2 - playlist.stop never returns (deadlock?)
Posted: 13 Aug 2014 20:41
Hi
I am creating a piece of software in WPF that uses VLC 2.1.3 ActiveX v2.
The program can be started multiple times and can play synchronized video on several screens.
I have a master application that communicates with the other programs and tells them what video to play or to jump to a specific location in a video.
Most of the time it works just fine!
Problem
Sometimes when wanting to stop a video, before starting a new one, one of the programs will hang in playlist.stop()
When debugging the C# code on the application that hangs, I can see that playlist.stop() never returns.
Cause
I can't reproduce it every time, but when changing videos fast it will happen eventually.
Below is the C# code that causes problems.
The vlcPlayer variable is the AxVLCPlugin2.
I am using "WindowsFormsHost" to host the ActiveX control in the WPF application.
It seems like it could be some sort of timing issue since it appears more or less random
Can it be a threading issue??
I really hope you clever guys have an answer to this!
Best regards
/Freddie
I am creating a piece of software in WPF that uses VLC 2.1.3 ActiveX v2.
The program can be started multiple times and can play synchronized video on several screens.
I have a master application that communicates with the other programs and tells them what video to play or to jump to a specific location in a video.
Most of the time it works just fine!
Problem
Sometimes when wanting to stop a video, before starting a new one, one of the programs will hang in playlist.stop()
When debugging the C# code on the application that hangs, I can see that playlist.stop() never returns.
Cause
I can't reproduce it every time, but when changing videos fast it will happen eventually.
Below is the C# code that causes problems.
The vlcPlayer variable is the AxVLCPlugin2.
I am using "WindowsFormsHost" to host the ActiveX control in the WPF application.
Code: Select all
private void SetPlayStatus(MediaPlayerCommand _playCommand)
{
if (VlcNotPresent) return;
var oldStaus = GetCurrentStatus(); // what is the play status before we apply the new play status
if (_playCommand == MediaPlayerCommand.Play)
{
if (oldStaus == MediaPlayerCommand.Pause)
{
vlcPlayer.playlist.play();
return;
}
var index = _playlist.IndexOf(currentMediaFile);
if (index < 0) // the playlist will always contain currentMediaFile, but just in case :-)
{
return;
}
vlcPlayer.playlist.playItem(index);
}
else if (oldStaus == MediaPlayerCommand.Play && _playCommand == MediaPlayerCommand.Pause)
{
vlcPlayer.playlist.pause();
}
else if (_playCommand == MediaPlayerCommand.Stop)
{
if (vlcPlayer.input.state == 3 || vlcPlayer.input.state == 4) // Checking if VLC is playing or is paused, added this to try and avoid my problem... but it has no effect
{
vlcPlayer.playlist.stop(); // this is where the application hangs
}
}
}
Can it be a threading issue??
I really hope you clever guys have an answer to this!
Best regards
/Freddie