Page 1 of 1

VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 13 Aug 2014 20:41
by ffr
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.

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 } } }
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

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 05 May 2015 21:22
by michael-h
Freddie,

Did you ever get a solution to this? I am getting exactly the same issue...

M.

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 05 May 2015 22:29
by Jean-Baptiste Kempf
What stream are you playgin?

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 08 May 2015 11:30
by ffr
Oh, first responses to this old post.

We are loading mp4 files into the playlist.
The problem might arise when using a playlist and trying to avoid auto change to next track we call stop on the playlist.
It is always in the transistion between movies.

This is what is happening in my appliction.
1) A movie is playing.
2) I stop this Movie
3) Find the next movie in the playlist
4) Play the found movie

To me it seems like there might be a deadlock between start and stop, because of the auto play and we can't disable that in the Active X (at least not to my knowlegde)

I did implement a bad hack where I put the stop command in a Thread and kill the thread if it takes to long.
This is really something I would like to get rid of, so please if you have any suggestions.

BR.
Freddie

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 08 May 2015 14:45
by Jean-Baptiste Kempf
Please share a test case, and we'll fix.

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 24 Mar 2016 11:20
by ivang
Hello,
I encountered the same problem. My application never returns from playlist.stop. Are there any news about the problem? Walk around?
Best regards Ivan

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 30 Sep 2016 22:25
by Jacoboon
This is the only post I've found that represents my problem. I TO have encountered this bug. I have a bot that plays videos mostly from youtube or m3u8's from twitch vods. It works fine most of the time with the exception that it sometimes fails to start or stop. Now, when it fails to start, it does not hang. I can simply (and sadly) skip the video and move on. However, when it fails to stop, it will hang indefinitely. The bot goes into 'not responding' status and must be force ended, and restarted. It is without a doubt the playlist.stop() method that never returns. I would have to install metrics to trace down if it has anything to do with WHICH video it's playing, sorry I do not have more info there.

I'd rather use VLC and not embed chromium. For the simple fact that I do not want to use anyone's embedded player when I can just do it this way.

I made an account just to post this message.

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 03 Oct 2016 12:48
by da2424
Can you see this problem with VLC 3.0, too?

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 05 Oct 2016 10:22
by Jacoboon
I didn't realize there was a v3. So I just checked, and I see it in the nightlies. I might have to wait until it's a stable release to try it out :/ Or I might just give it a go anyway. Either way I will post a follow up eventually.

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 07 Oct 2016 18:37
by da2424
You can find the nightlies on http://nightlies.videolan.org/

Re: VLC Activex V2 - playlist.stop never returns (deadlock?)

Posted: 24 Aug 2018 00:23
by novan
I had a similar issue happening to me when I replaced my Windows Media Player plugin with the VLC one. My application was occasionally freezing when I would switch videos. After reading the OP's post I started experimenting with managing how I stopped the playing video and switched to a new one using only files over 4GB. With files of that size I was consistently able to recreate the error which told me that it had something to do with how long the player was taking to stop the playing large video files before it tried to load the next one. The issue completely went away if I hit the stop button and then selected the next video.

I added the following to my VB code:
For DC = 1 To 1000000
Application.DoEvents()
Next

I first used Thread.sleep but did not like how it locked the application for 2 seconds. It will probably work with a smaller number, but I was not concerned with finding the lowest possible number.

Anyway the loop solved the problem and I was able to use the Next Video button in my application to successfully cycle through my videos without the application failing. However I discovered that when I used my application's video browser to select a video it would still freeze. Because my video browser shrinks the player my guess is that the resize and swapping of video was too much for the player to handle. I modified my player so that it only closed the browser after the new video was successfully loaded and that solved the problem.