2022年8月17日 星期三

embeded vlc streaming play

 Ref-https://www.cnblogs.com/cplemom/p/13956092.html

WPF app + embedded vlc players

1. new wpf project   framework 4.7.2

2. add nuget package

Install-Package Vlc.DotNet.Wpf -Version 3.1.0

Vlc.DotNet.Core

Vlc.DotNet.Core.Interops

Vlc.DotNet.Wpf

3. xmal file ; add xmlns 

 xmlns:v="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"

4. xaml file add 2 VlcControl

<Grid x:Name="g1" >

        <Grid>

            <v:VlcControl Name="vlcControl1" Margin="427,0,0,0"/>

        </Grid>

        <Grid>

            <v:VlcControl Name="vlcControl2" Margin="0,0,413,0"/>

        </Grid>

    </Grid>

5. xaml.cs file x64 vlcplay 

InitializeComponent();

string VLCPath = @"C:\Program Files\VideoLAN\VLC";

vlcControl1.SourceProvider.CreatePlayer(new System.IO.DirectoryInfo(VLCPath));

string url = @"https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_30MB.mp4";

if (!string.IsNullOrWhiteSpace(url))

{

      vlcControl1.SourceProvider.MediaPlayer.Play(new Uri(url));

}

vlcControl2.SourceProvider.CreatePlayer(new System.IO.DirectoryInfo(VLCPath));

string url2 = @"rtmp://192.168.1.102/stream/passingcode";

            if (!string.IsNullOrWhiteSpace(url2))

            {

                vlcControl2.SourceProvider.MediaPlayer.Play(new Uri(url2));

            }

5. Select x64 mode 

6. excute rtmp://192.168.1.102/stream/passingcode

7. run

8.Result :