static void Main(string[] args) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var destination = Path.Combine(currentDirectory, "record.ts"); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#file{dst=" + destination + "}", ":sout-keep" }; mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"), mediaOptions); mediaPlayer.Play(); Console.WriteLine($"Recording in {destination}"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
private static void ExperimentVLC() { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); Trace.WriteLine($"VLC: {libDirectory}"); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory, new string[] { "-v" })) { //var mediaOptions = new[] //{ // //":sout=#rtp{sdp=rtsp://127.0.0.1:554/}", // //":sout-keep" //}; Console.WriteLine("Setting Media"); mediaPlayer.SetMedia(new Uri("http://www.streamingsoundtracks.com/modules/Listen/MP3-hi.pls")); //mediaPlayer.SetMedia(new Uri("http://hi.streamingsoundtracks.com")); //mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8")); //mediaPlayer.SetMedia(new FileInfo(@"D:\jonatan\Music\Library\Adam Taylor\The Handmaid's Tale\01 Escapes Within (Elisabeth Moss Narration).mp3")); Console.WriteLine("Playing"); mediaPlayer.Play(); //Console.WriteLine("Fading in"); //for (int i = 5; i <= 10; i++) //{ // Thread.Sleep(500); // mediaPlayer.Audio.Volume = i * 10; //} Console.ReadKey(); mediaPlayer.Stop(); } }
static void Main() { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#rtp{sdp=rtsp://127.0.0.1:554/}", ":sout-keep" }; mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"), mediaOptions); mediaPlayer.Play(); Console.WriteLine("Streaming on rtsp://127.0.0.1:554/"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
private void Record() { var libDirectory = this.vlcControl1.VlcLibDirectory; var options = new string[] { "-vv" // VLC options can be given here. Please refer to the VLC command line documentation. }; mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory); var mediaOptions = new string[] { ":sout=#file{dst=" + Path.Combine(Environment.CurrentDirectory, "output.mov") + "}", ":sout-keep" }; mediaPlayer.SetMedia(new Uri("http://192.168.81.125:5050/video_feed"), mediaOptions); mediaPlayer.Play(); /* * https://github.com/ZeBobo5/Vlc.DotNet/wiki/Getting-started * */ }
public static void Play(string filePath) { var libDirectory = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory); mediaPlayer.SetMedia(new FileInfo(filePath)); bool playFinished = false; mediaPlayer.EncounteredError += (sender, e) => { playFinished = true; }; mediaPlayer.EndReached += (sender, e) => { playFinished = true; }; mediaPlayer.Play(); while (!playFinished) { Thread.Sleep(TimeSpan.FromMilliseconds(500)); } }
static void Main(string[] args) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var destination = Path.Combine(currentDirectory, "record.ts"); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#file{dst=" + destination + "}", ":sout-keep" }; mediaPlayer.SetMedia(new Uri("http://demo.macroscop.com:8080/mobile?login=root&channelid=2016897c-8be5-4a80-b1a3-7f79a9ec729c&resolutionX=640&resolutionY=480&fps=25"), mediaOptions); mediaPlayer.Play(); Console.WriteLine($"Recording in {destination}"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
private void AddMovieURL_Click(object sender, RoutedEventArgs e) { //Uri url = new Uri(movieUrl.Text); // string movieCode = url.Query.Remove(0,3); //string path = "http://www.youtube.com/embed/" + movieCode ; FileInfo file = new FileInfo(@"C:\Users\Martusia\source\repos\BroadcasterIndes\Resources\1.mp4"); var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#rtp{sdp=rtsp://192.168.1.162:8008/test}", ":sout-keep" }; // mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"), // mediaOptions); mediaPlayer.SetMedia(file, mediaOptions); mediaPlayer.Play(); // Streaming on rtsp://192.168.1.162:8008/test } }
public void Dispose() { if (this._player != null) { this._player.Stop(); this._player.Dispose(); this._player = null; } }
//private SolidBrush testBrush = new SolidBrush(Color.FromArgb(200, 31, 31)); #endregion public VLC(Rect2D rect) : base(rect) { this.VlcBmp = new System.Drawing.Bitmap(500, 500); player = new Vlc.DotNet.Core.VlcMediaPlayer(new DirectoryInfo(@"D:\LibVlc")); player.SetMedia(new FileInfo("J:\\Video\\Klipai\\√Bestamvsofalltime ▪ Aevum AMV.mp4")); //player.VideoHostControlHandle = this.Handle; //v.Video.Tracks.Current. player.Play(); //VlcBmp. }
public async Task Transcode() { try { Console.OutputEncoding = System.Text.Encoding.UTF8; var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var destination = Path.Combine(currentDirectory + "\\wwwroot"); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#transcode{vcodec=h264, vb=300, venc=x264, fps=15, width=352, height=288, acodec=mp3, aenc=ffmpeg, samplerate=44100, threads=2}:standard{access=file,mux=mp4,dst=" + destination + "\\6.mp4" }; //var mediaOptions = new[] //{ // ":sout=#transcode{vcodec=theo}:std{access=http,mux=ogg,dst=:8090}", // ":sout-keep" //}; //":sout=#transcode{vcodec=h264,vb072}:standard{access=file,mux=mp4,dst=D:\\Work\\Test\\Video\\Video\\bin\\Debug\\wwwroot\\6.mp4" //mediaPlayer.SetMedia(new Uri("http://58.222.132.163:17000/pag/172.21.41.136/7302/009120/0/MAIN/TCP/live.m3u8"), // mediaOptions); // 打开文件 FileStream fileStream = new FileStream(destination + "\\4.mp4", FileMode.Open, FileAccess.Read, FileShare.Read); // 读取文件的 byte[] byte[] bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, bytes.Length); fileStream.Close(); // 把 byte[] 转换成 Stream Stream stream = new MemoryStream(bytes); mediaPlayer.SetMedia(stream, mediaOptions); TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); mediaPlayer.EndReached += (sender, e) => { ThreadPool.QueueUserWorkItem(_ => tcs.TrySetResult(true)); }; mediaPlayer.Play(); await tcs.Task; } } catch (Exception e) { Console.WriteLine(e.Message); } }
public void TestMethod1() { WindowsDriver <WindowsElement> myDriver = null; AppiumOptions appOptions = new AppiumOptions(); appOptions.AddAdditionalCapability("app", @"C:\Program Files\VideoLAN\VLC\vlc.exe"); myDriver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appOptions); myDriver.Manage().Window.Maximize(); myDriver.FindElementByClassName("Media").Click(); FileInfo file = new FileInfo(@"C:\Users\praj9\Downloads\C#-embed-vlc.mp4"); var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { // var mediaOptions = new[] { // ":sout=#rtp{sdp=rtsp://192.168.1.7:8008/test.sdp}", // ":sout-keep" // }; mediaPlayer.SetMedia(new Uri("https://www.youtube.com/watch?v=e7EStbS1TWk")); //mediaOptions); // mediaPlayer.SetMedia(file, mediaOptions); mediaPlayer.Play(file); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } } }
public Form1() { InitializeComponent(); api = new QQMusicAPI(); var dir = new FileInfo(this.GetType().Assembly.Location).Directory.FullName; var libDirectory = new DirectoryInfo(Path.Combine(dir, "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. }; mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory); mediaPlayer.Buffering += MediaPlayer_Buffering; mediaPlayer.EndReached += MediaPlayer_EndReached; mediaPlayer.MediaChanged += MediaPlayer_MediaChanged; mediaPlayer.Playing += MediaPlayer_Playing; mediaPlayer.Stopped += MediaPlayer_Stopped; mediaPlayer.TimeChanged += MediaPlayer_TimeChanged; this.FormClosing += (a, b) => mediaPlayer.Dispose(); }
static void Main(string[] args) { FileInfo file = new FileInfo(@"C:\Users\Jman\VideoMaker.avi"); var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#rtp{sdp=rtsp://192.168.1.162:8008/test}", ":sout-keep" }; //mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"), // mediaOptions); mediaPlayer.SetMedia(file, mediaOptions); mediaPlayer.Play(); Console.WriteLine("Streaming on rtsp://192.168.1.162:8008/test"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public static async Task Main(string[] args) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var destinationFolder = Path.Combine(currentDirectory, "thumbnails"); if (!Directory.Exists(destinationFolder)) { Directory.CreateDirectory(destinationFolder); } var options = new[] { "--intf", "dummy", /* no interface */ "--vout", "dummy", /* we don't want video output */ "--no-audio", /* we don't want audio decoding */ "--no-video-title-show", /* nor the filename displayed */ "--no-stats", /* no stats */ "--no-sub-autodetect-file", /* we don't want subtitles */ "--no-snapshot-preview", /* no blending in dummy vout */ }; using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory, options)) { mediaPlayer.SetMedia( new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov")); TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); var lastSnapshot = 0L; mediaPlayer.TimeChanged += (sender, e) => { // Maps the time to a 5-seconds interval to take a snapshot every 5 seconds var snapshotInterval = e.NewTime / 5000; // Take a snapshot every 5 seconds if (snapshotInterval > lastSnapshot) { lastSnapshot = snapshotInterval; ThreadPool.QueueUserWorkItem(_ => { mediaPlayer.TakeSnapshot(0, Path.Combine(destinationFolder, $"{snapshotInterval}.png"), 1024, 0); }); } }; mediaPlayer.EncounteredError += (sender, e) => { Console.Error.Write("An error occurred"); tcs.TrySetCanceled(); }; mediaPlayer.EndReached += (sender, e) => { ThreadPool.QueueUserWorkItem(_ => tcs.TrySetResult(true)); }; mediaPlayer.Play(); await tcs.Task; } }
private void btnPlay_Click(object sender, RoutedEventArgs e) { Vlc.DotNet.Core.VlcMediaPlayer player2 = new Vlc.DotNet.Core.VlcMediaPlayer(); player.Play(new Uri(txtURI.Text)); }
private void bgwRecording_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; Channel channel = (Channel)e.Argument; VideoMetadata videoMetadata = new VideoMetadata(); try { // Check if current channel is playing before trying to record if (currentChannel.IsPlaying) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var destinationDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "MagyarTV"); if (!File.Exists(destinationDir)) { try { Directory.CreateDirectory(destinationDir); } catch (Exception ex) { Logger.Error(ex); } } var destination = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "MagyarTV", channel.StreamInfo.Title + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".ts"); /// New definition of mediaPlayer using (var mediaRecorder = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory)) { var mediaOptions = new[] { ":sout=#file{dst=" + destination + "}", ":sout-keep" }; currentChannel.IsRecording = true; MediaKlikk mediaKlikk = new MediaKlikk(); mediaRecorder.SetMedia(new Uri(mediaKlikk.GetChannelURI(currentChannel)), mediaOptions); btRecord.ForeColor = Color.Red; mediaRecorder.Play(); currentRecording.Channel = channel; Logger.Info(String.Format("Recording channel {0} to {1}.", currentChannel.Name, destination)); if (backgroundWorker != null) { while (!backgroundWorker.CancellationPending) { // Update } if (backgroundWorker.CancellationPending) { Logger.Info(String.Format("Cancelled recording channel {0}.", currentChannel.Name)); btRecord.ForeColor = Color.Black; e.Cancel = true; } } } } } catch (Exception ex) { Logger.Error("Failed to start recording"); Logger.Error(ex); MessageBox.Show(String.Format("Failed to start recording. {0}", ex.Message)); } }
public VlcPlayer(int volume) { this._player = new Vlc.DotNet.Core.VlcMediaPlayer(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "lib_vlc"))); this._player.Log += _player_Log; setVolume(volume); }
private void btnPlay_Click(object sender, RoutedEventArgs e) { Vlc.DotNet.Core.VlcMediaPlayer player2 = new Vlc.DotNet.Core.VlcMediaPlayer(); player.Play(new Uri(txtURI.Text)); }
public VlcPlayer() { player = new Vlc.DotNet.Core.VlcMediaPlayer(new System.IO.DirectoryInfo(@"LibVlc")); }