我有一个UWP应用(目标版本1903 Build 18362),我想在其中嵌入VLC视频播放器。这就是我的经历:
结果:当我捕获事件时,他说他正在缓冲和播放,但是没有视频也没有音频。
结果:当我捕获事件时,他说他正在缓冲和播放,我听到了声音,但是没有视频。
我在做什么错?
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();
}
}
}
请看https://github.com/videolan/libvlcsharp/tree/3.x/Samples/LibVLCSharp.UWP.Sample
使用LVS 3.x / Libvlc 3.x中的当前设计,在创建new LibVLC()
时需要设置交换链选项。