下载vlc并复制以下文件
<Page x:Class="test003.View.User.UserCenter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:test003.View.User"
xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
mc:Ignorable="d"
Title="UserCenter" Height="Auto" Width="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<wpf:VlcControl Grid.Row="0" x:Name="MyVlcControl" />
<Button Grid.Row="1" x:Name="btnPlay" Height="30" Width="120" Content="播放" />
</Grid>
</Page>
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace test003.View.User
{
public partial class UserCenter : Page
{
//保存引用的元素
public UserCenter()
{
InitializeComponent();
btnPlay.Click += BtnPlay_Click;
//初始化配置,指定引用库
var vlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
var options = new string[]
{
// VLC options can be given here. Please refer to the VLC command line documentation.
};
MyVlcControl.SourceProvider.CreatePlayer(vlcLibDirectory, options);
}
private void BtnPlay_Click(object sender, RoutedEventArgs e)
{
MyVlcControl.SourceProvider.MediaPlayer.Play(
new Uri("http://ivi.bupt.edu.cn/hls/cctv3hd.m3u8"));
}
}
}