[英]C# Vlc Player Mouse Double Click Event
I am working on a player developed using libvlc, c#. 我正在研究使用libvlc开发的播放器,c#。 There is working fullscreen button.
有全屏按钮。 I tried to add mousedoubleclick event to panel(plays video), its working when we are not playing video;
我试图将mousedoubleclick事件添加到面板(播放视频),它在我们不播放视频时工作; but it does not work when video starts to play.
但是当视频开始播放时它不起作用。 Therefore i have added same event into player but still does not work.
因此我将相同的事件添加到播放器中但仍然无效。
Definition of Event: 事件的定义:
this.player.MouseDoubleClick += new MouseEventHandler(panel1_MouseDoubleClick);
Definition: 定义:
private vlc.DotNet.Forms.VlcControl player;
Is there any other way to add mouse double click event into vlc player? 有没有其他方法将鼠标双击事件添加到vlc播放器?
Panel1: "panelVideo" holds "Vlc.DotNet.Forms.VlcControl" Panel1: “panelVideo”持有“Vlc.DotNet.Forms.VlcControl”
Panel2: "panelDoubleClick" created at runtime and "vlcControl.Controls.Add(panelDoubleClick);" Panel2:在运行时创建的“panelDoubleClick”和“vlcControl.Controls.Add(panelDoubleClick);”
Panel2: set panelDoubleClick.BackColor = Color.Transparent ; Panel2: set panelDoubleClick.BackColor = Color.Transparent ;
Panel2: add double click event hantler for toggle full screen panelDoubleClick.MouseDoubleClick += new MouseEventHandler(panelDoubleClick_MouseDoubleClick); Panel2:添加双击事件hantler以切换全屏panelDoubleClick.MouseDoubleClick + = new MouseEventHandler(panelDoubleClick_MouseDoubleClick);
Vlc.DotNet.Forms.VlcControl vlcControl;
Vlc.DotNet.Core.Medias.PathMedia Media2Play;
public void PlayMedia(string fileName)
{
if (Vlc.DotNet.Core.VlcContext.IsInitialized == false)
initVLC();
//StopVLC();
//Panel1: "panelVideo" holds "Vlc.DotNet.Forms.VlcControl"
//Panel2: "panelDoubleClick" created at runtime and "vlcControl.Controls.Add(panelDoubleClick);"
//Panel2: panelDoubleClick.BackColor = Color.Transparent;
//panelDoubleClick.MouseDoubleClick += panelDoubleClick_MouseDoubleClick;
vlcControl = new Vlc.DotNet.Forms.VlcControl();
vlcControl.CreateControl();
vlcControl.Dock = DockStyle.Fill;
this.panelVideo.Controls.Add(vlcControl);//panelVideo is manin container panel.
//initEvents();//VLC player events
Panel panelDoubleClick = new Panel();// this panel requires to catche double click evetns.
panelDoubleClick.Dock = DockStyle.Fill;
panelDoubleClick.BackColor = Color.Transparent;
panelDoubleClick.MouseDoubleClick += new MouseEventHandler(panelDoubleClick_MouseDoubleClick); ;
if (vlcControl != null)
{
Media2Play = new Vlc.DotNet.Core.Medias.PathMedia(fileName);
vlcControl.Media = Media2Play;
vlcControl.Show();
vlcControl.Play();
vlcControl.Controls.Add(panelDoubleClick);
panelDoubleClick.BringToFront();
}
}
private void panelDoubleClick_MouseDoubleClick(object sender, MouseEventArgs e)
{
MessageBox.Show ("ToggleFullScreen();");
}
private void initVLC()
{
try
{
// Set libvlc.dll and libvlccore.dll directory path
string vlcPath = "";
vlcPath = "E:\\VLC\\VLC_minimal";
if (System.IO.Directory.Exists(vlcPath) == false)
{
vlcPath = Application.StartupPath.Trim('\\') + "\\VLC\\";
if (System.IO.Directory.Exists(vlcPath) == false)
{
if (Environment.Is64BitOperatingSystem)
{
vlcPath = "C:\\Program Files (x86)\\VideoLAN\\VLC";
}
else
{
vlcPath = "C:\\Program Files\\VideoLAN\\VLC";
}
if (System.IO.Directory.Exists(vlcPath) == false)
{
MessageBox.Show("VLC cannot be fount on your system.");
Application.Exit();
return;
}
}
}
Vlc.DotNet.Core.VlcContext.LibVlcDllsPath = vlcPath;
// CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
// Set the vlc plugins directory path
Vlc.DotNet.Core.VlcContext.LibVlcPluginsPath = Vlc.DotNet.Core.VlcContext.LibVlcDllsPath + "\\pugins";
//CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
// Ignore the VLC configuration file
Vlc.DotNet.Core.VlcContext.StartupOptions.IgnoreConfig = true;
// Enable file based logging
Vlc.DotNet.Core.VlcContext.StartupOptions.LogOptions.LogInFile = false;
// Shows the VLC log console (in addition to the applications window)
Vlc.DotNet.Core.VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
// Set the log level for the VLC instance
Vlc.DotNet.Core.VlcContext.StartupOptions.LogOptions.Verbosity = Vlc.DotNet.Core.VlcLogVerbosities.None;
Vlc.DotNet.Core.VlcContext.StartupOptions.ScreenSaverEnabled = false;
Vlc.DotNet.Core.VlcContext.StartupOptions.AddOption("--no-video-title");
//hide played media filename on startingto play media.
// Initialize the VlcContext
Vlc.DotNet.Core.VlcContext.Initialize();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.