Skip to content

MediaPlayer.Stop hangs when the player is connecting to another media

Summary

When the player is connecting to a media, MediaPlayer.Stop hangs until the media is playing or until a timeout occurs ~5sec.

Minimal project and steps to reproduce

Based on the NetCoreSample

        static void Main(string[] args)
        {
            Core.Initialize();

            var libVlc = new LibVLC();
            var media = new Media(libVlc, "rtsp://10.42.42.42", FromType.FromLocation);
            var mp = new MediaPlayer(media);

            var sw = Stopwatch.StartNew();
            mp.Play();

            Console.WriteLine($"Play : {sw.Elapsed}");
            sw.Restart();

            mp.Stop();
            Console.WriteLine($"Stop : {sw.Elapsed}");
        }

Play : 00:00:00.0031509

Stop : 00:00:05.0607937

    <PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.8" />
    <PackageReference Include="LibVLCSharp" Version="3.2.1" />

What is the current bug behavior?

mp.Stop() blocks the application during ~5 seconds.

What is the expected correct behavior?

mp.Stop() doesn't block the application, and it is possible to immediately play another media.

Environment

  • OS: Windows 10 1903
  • LibVLC 3.0.8 x64
  • LibVLCSharp 3.2.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information