Search code examples
c#xamluwpvlclibvlcsharp

UWP with LibVLC.UWP no video and/or audio?


I have a UWP app (target version 1903 Build 18362) where I want to embed the VLC video player. This is what I experienced:

  1. Adding LibVLCSharp 3.3.1
  2. Adding VideoLAN.LibVLC.UWP 3.2.0

Result: when I capture events he says he's buffering and playing, but no video and no audio.

  1. Reverting to VideoLAN.LibVLC.UWP 3.1.1.1

Result: when I capture events he says he's buffering and playing, I hear the audio, but no video.

What am I doing wrong?

MainPage.Xaml:

<Page
    x:Class="TestVLCinUWP.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TestVLCinUWP"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vlc="using:LibVLCSharp.Platforms.UWP"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <vlc:VideoView x:Name="Video" Width="960" Height="540" />
    </Grid>
</Page>

MainPage.xaml.cs:

using LibVLCSharp.Shared;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestVLCinUWP
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            Core.Initialize();

            this.InitializeComponent();

            Loaded += MainPage_Loaded;
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            LibVLC vlc = new LibVLC();
            var media = new Media(vlc, "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4", FromType.FromLocation);
            MediaPlayer player = new MediaPlayer(media);
            Video.MediaPlayer = player;
            player.Play();
        }
    }
}

Solution

  • Please have a look at https://github.com/videolan/libvlcsharp/tree/3.x/Samples/LibVLCSharp.UWP.Sample

    With the current design in LVS 3.x /Libvlc 3.x, you need to set your swapchain options when you create your new LibVLC().

    As for the audio, this is a known issue : https://code.videolan.org/videolan/LibVLCSharp/issues/253