Search code examples
c#xamarinxamarin.formsvlclibvlcsharp

Vlc player black screen on Xamarin.Forms


the video is playing normally, but if you open another application and go back, vlc will show a black screen with a only sound. (Android 8.0.0, last version of nuget package)

LibVLC libVLC = new LibVLC("--preferred-resolution=-1", " --log-verbose=3", "--no-gnutls-system-trust");
MediaPlayer mediaPlayer;
Media media = new Media(libVLC, playerUrl, FromType.FromLocation);
VideoView1.MediaPlayer = mediaPlayer;
mediaPlayer.Play();

Solution

  • On Android, background support needs a bit of ceremony due to how the OS works. Simply, it means you need to recreate a VideoView and set your existing MediaPlayer on it to have video working when coming back from the background.

    Sample demonstrating this is available https://code.videolan.org/mfkl/libvlcsharp-samples/-/tree/master/ForegroundBackground