1

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();
        }
    }
}
Martin Tirion
  • 1,246
  • 1
  • 7
  • 10

1 Answers1

1

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

cube45
  • 3,429
  • 2
  • 24
  • 35
  • And there is an open bug for audio with libvlc uwp 3.2 – mfkl Nov 14 '19 at 02:25
  • Thanks @cube45, that works ... well, for the 3.1.1.1 version of VideoLAN.LibVLC.UWP. If I switch to 3.2.0 the audio is now gone, video is still there. – Martin Tirion Nov 14 '19 at 13:06
  • As @mtz said, the audio part is a known issue. I forgot that part in my reply, and I just edited it. – cube45 Nov 14 '19 at 16:00
  • Do you know how to retrieve these `swapchain` options manually? The Initialize command is never fired in my own project, probably because the `Grid` is `Collapsed` that contains the `VideoView`. Or how to manually initialize the VideoView. – CularBytes Dec 13 '19 at 11:05
  • nvm found it, had to change the `Binding` to `x:Bind` because I was binding to the view.cs instead of using the `Page.DataContext` – CularBytes Dec 13 '19 at 11:18