74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Windows.Forms;
|
|
using Vlc.DotNet.Forms;
|
|
|
|
namespace PlumByteUI_Learn
|
|
{
|
|
public partial class PlayerView : UserControl
|
|
{
|
|
public PlayerView()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void PlayerView_Load(object sender, EventArgs e)
|
|
{
|
|
// string[] options = { ":network-caching=100", ":rtsp-tcp"};// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none}
|
|
// var videoUri = new Uri(@"rtsp://127.0.0.1:8554/rains");
|
|
// vlcControl.Play(videoUri, options);
|
|
// vlcControl.Controls
|
|
|
|
// using(SaveFileDialog sfd = new SaveFileDialog())
|
|
// {
|
|
// sfd.Filter = "jpg文件 | *.jpg";
|
|
// if(sfd.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// vlcControl.TakeSnapshot(sfd.FileName);
|
|
// }
|
|
// }
|
|
}
|
|
|
|
private void vlcControl_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void vlcControl_VlcLibDirectoryNeeded(object sender, VlcLibDirectoryNeededEventArgs e)
|
|
{
|
|
var currentAssembly = Assembly.GetEntryAssembly();
|
|
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
|
|
|
|
if (currentDirectory == null)
|
|
return;
|
|
if (IntPtr.Size == 4)
|
|
e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x86\"));
|
|
else
|
|
e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x64\"));
|
|
|
|
if (!e.VlcLibDirectory.Exists)
|
|
{
|
|
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
folderBrowserDialog.Description = "Select Vlc libraries folder.";
|
|
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
|
|
folderBrowserDialog.ShowNewFolderButton = true;
|
|
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 播放按钮
|
|
*/
|
|
private void playBtn_Click(object sender, EventArgs e)
|
|
{
|
|
string[] options = { ":network-caching=10", ":rtsp-tcp"};// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none}
|
|
var videoUri = new Uri(@"rtsp://127.0.0.1:8554/rains");
|
|
vlcControl.Play(videoUri, options);
|
|
Console.WriteLine("播放rtsp视频");
|
|
}
|
|
}
|
|
} |