基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Vlc.DotNet.Forms;
|
||||
|
||||
namespace RFIDManagement
|
||||
{
|
||||
public partial class FrmVlcPlayer : Form
|
||||
{
|
||||
public SynchronizationContext SyncContext;
|
||||
public VlcControl VlcPlayer;
|
||||
public FrmVlcPlayer()
|
||||
{
|
||||
InitializeComponent();
|
||||
SyncContext = SynchronizationContext.Current;
|
||||
var currentAssembly = Assembly.GetEntryAssembly();
|
||||
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
|
||||
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
|
||||
VlcPlayer = new VlcControl();
|
||||
VlcPlayer.BeginInit();
|
||||
VlcPlayer.VlcLibDirectory = libDirectory;
|
||||
VlcPlayer.Dock = DockStyle.Fill;
|
||||
VlcPlayer.EndInit();
|
||||
VlcPlayer.EndReached += OnVlcPlayerEndReached;
|
||||
this.Controls.Add(VlcPlayer);
|
||||
this.FormClosed += OnFrmVlcPlayerFormClosed;
|
||||
}
|
||||
public void PlayVideo(string url)
|
||||
{
|
||||
VlcPlayer.SetMedia(new Uri(url));
|
||||
VlcPlayer.Play();
|
||||
}
|
||||
public void CloseWindow(object state)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// 播放完成后
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnVlcPlayerEndReached(object sender, Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e)
|
||||
{
|
||||
SyncContext.Post(CloseWindow, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// 程序关闭后
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnFrmVlcPlayerFormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
VlcPlayer?.Stop();
|
||||
VlcPlayer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user