티스토리 뷰

c#

[wpf/c#] vlc player 개발 및 라이브러리 사용법

개발자 고포고 2022. 10. 27. 15:53
반응형

[wpf/c#] vlc player 개발 및 라이브러리 사용법

 

 

#패키지 추가

-Vlc.DotNet.Wpf

-Vlc.DotNet.Core

 

#Control 추가 Xaml

<Window x:Class="SE_Display.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
        xmlns:local="clr-namespace:SE_Display"
        mc:Ignorable="d" 
          Title="MainWindow" Background="Black" WindowStyle="None" WindowState="Normal" ResizeMode="NoResize" Left="0" Top="0" Width="2560" Height="640">
    <Grid >
        <Grid x:Name="MediaGrid" Width="6400" Height="1600" >
            <Grid Grid.Column="0" x:Name="Singlemovie_Grid">
                <vlc:VlcControl  x:Name="Singlemovie_vlc" />
            </Grid>
        </Grid>
    </Grid>
</Window>

 

# c# 초기화

   public VlcMediaPlayer video;
        void InitVlc()
        {
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            var libDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
            this.Singlemovie_vlc.SourceProvider.CreatePlayer(libDirectory);
            video = Singlemovie_vlc.SourceProvider.MediaPlayer;
        }

 

# 기본 사용

  video.Play(new Uri(currentPath + @"\0.mp4"));
            audio.Open(new Uri(currentPath+@"\0.mp3"));
            video.EndReached += Video_EndReached;
            video.SetPause(true);

 

 

#라이브러리 -Debug or Release 폴더에 다음 라이브러리를 복사한다

https://drive.google.com/file/d/1YjQURQOmBok0nNxJa3O0xlrCtEJ6iN6H/view?usp=sharing

 

#vlc #wpf #mediaelement #미디어엘리먼트 #브이엘씨 #c#

반응형
댓글
반응형