基于VLC的C#播放器源码
实现的功能:
1:打开播放的音视频文件((1)菜单栏“文件”->“打开”,(2)工具栏(下面)“打开”(3)播放器右键->打开)
2:暂停,继续播放,停止音视频文件
3:进度条和右下角文本框显示播放进度
4:拖动进度条对视频定位播放
5:工具栏(下面)“快进”,“快退”均为5s
6:音量调节
7:菜单栏“文件”下可记录最近播放的三个文件
8:在有记录的情况下,初始状态时双击视频播放区或单击“播放”播放上次关闭时播放的视频
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 36864 2016-04-24 22:21 mediaPlayer_VLCmediaPlayer.suo
文件 1023 2016-04-25 09:50 mediaPlayer_VLCmediaPlayer_VLC.sln
..A..H. 36864 2016-04-25 09:31 mediaPlayer_VLCmediaPlayer_VLC.suo
..A..H. 62464 2016-04-28 10:21 mediaPlayer_VLCmediaPlayer_VLC.v12.suo
文件 187 2016-04-24 19:47 mediaPlayer_VLCWindowsFormsApplication1App.config
文件 53760 2016-04-24 19:49 mediaPlayer_VLCWindowsFormsApplication1inDebugAxInterop.WMPLib.dll
文件 330752 2016-04-25 09:50 mediaPlayer_VLCWindowsFormsApplication1inDebugInterop.WMPLib.dll
文件 143296 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebuglibvlc.dll
文件 2631616 2015-04-13 22:00 mediaPlayer_VLCWindowsFormsApplication1inDebuglibvlccore.dll
文件 115 2016-04-28 09:38 mediaPlayer_VLCWindowsFormsApplication1inDebugMenu.ini
文件 114112 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibaccess_bd_plugin.dll
文件 88512 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibaccess_mms_plugin.dll
文件 115136 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibaccess_realrtsp_plugin.dll
文件 22464 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibattachment_plugin.dll
文件 637238 2015-04-13 21:56 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibbluray-j2se-0.7.0.jar
文件 171968 2015-04-13 21:58 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibcdda_plugin.dll
文件 554944 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibdshow_plugin.dll
文件 265152 2015-04-13 21:58 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibdtv_plugin.dll
文件 245184 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibdvdnav_plugin.dll
文件 166848 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibdvdread_plugin.dll
文件 55744 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibfilesystem_plugin.dll
文件 98752 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibftp_plugin.dll
文件 127936 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibhttp_plugin.dll
文件 22976 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibidummy_plugin.dll
文件 56768 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibimem_plugin.dll
文件 2158528 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccessliblibbluray_plugin.dll
文件 720832 2015-04-13 21:58 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccessliblive555_plugin.dll
文件 52672 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibrar_plugin.dll
文件 534976 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibrtp_plugin.dll
文件 29632 2015-04-13 21:57 mediaPlayer_VLCWindowsFormsApplication1inDebugpluginsaccesslibscreen_plugin.dll
............此处省略751个文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string address;
private VlcPlayer vlcPlayer;
private bool is_playinig;
private bool media_is_open;//标记媒体文件是否打开,若未打开则tsbtn_play读ini打开之前的文件,若打开则跳过这步(避免每次都打开文件造成屏幕跳动)
public Form1()
{
InitializeComponent();
address = Environment.CurrentDirectory;
}
private void Form1_Load(object sender EventArgs e)
{
label_media_name.Hide();
if (!File.Exists(address + “\Menu.ini“))
{
FileStream fs = new FileStream(address + “\Menu.ini“ FileMode.Create FileAccess.Write);
fs.Close();
}
string pluginPath = System.Environment.CurrentDirectory + “\plugins\“;
vlcPlayer = new VlcPlayer(pluginPath);
IntPtr render_wnd = this.panel1.Handle;
vlcPlayer.SetRenderWindow((int)render_wnd);
tbVideoTime.Text = “00:00:00/00:00:00“;
is_playinig = false;
media_is_open = false;
trackBar2.Value = 50;
this.Size = new Size(800 600);
// readFilePath();
}
///
/// 菜单栏文件实现功能
/// 1 打开待播放文件
/// 2 记录历史信息
/// 3 历史信息最多不超过3条
/// 4 点击历史信息可以实现播放menuitem_Click()
/// 5 如果点击历史信息不能播放(出现错误)则删除该历史信息item和Menu.ini (方法:try catch)
/// 6 Menu.ini记录的信息最多不超过3条不重复记录
/// 7 在历史信息中右键可以选择删除
///
///
///
///
#region 菜单栏-文件
///
/// 打开ToolStripMenuItem_Click
/// 打开文件并将文件目录添加到Menu.ini
/// 若打开相同文件则不添加(这个有Bug这样的话按tsBtn_play打开的就不是上一个了,因为打开相同的不添加)
/// 若记录行数超过3个,则先记录后三个数据,再重新建一个Menu.ini(清除数据)接着讲记录的后三个数据写入
///
///
///
///
private void 打开ToolStripMenuItem_Click(object sender EventArgs e)
{
//bool isSame = false;
openFileDialog1.FileName = ““;
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
{
//StreamReader sr0 = new StreamReader(address + “\Menu.ini“ true);
// while (sr0.Peek() > -1)
// {
// if ((sr0.ReadLine() == openFileDialog1.FileName)|(openFileDialog1.FileName==““))
// {
// isSame = true;
// }
// }
// sr0.Close();
// if (is
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 36864 2016-04-24 22:21 mediaPla
文件 1023 2016-04-25 09:50 mediaPla
..A..H. 36864 2016-04-25 09:31 mediaPla
..A..H. 62464 2016-04-28 10:21 mediaPla
文件 187 2016-04-24 19:47 mediaPla
文件 53760 2016-04-24 19:49 mediaPla
文件 330752 2016-04-25 09:50 mediaPla
文件 143296 2015-04-13 21:57 mediaPla
文件 2631616 2015-04-13 22:00 mediaPla
文件 115 2016-04-28 09:38 mediaPla
文件 114112 2015-04-13 21:57 mediaPla
文件 88512 2015-04-13 21:57 mediaPla
文件 115136 2015-04-13 21:57 mediaPla
文件 22464 2015-04-13 21:57 mediaPla
文件 637238 2015-04-13 21:56 mediaPla
文件 171968 2015-04-13 21:58 mediaPla
文件 554944 2015-04-13 21:57 mediaPla
文件 265152 2015-04-13 21:58 mediaPla
文件 245184 2015-04-13 21:57 mediaPla
文件 166848 2015-04-13 21:57 mediaPla
文件 55744 2015-04-13 21:57 mediaPla
文件 98752 2015-04-13 21:57 mediaPla
文件 127936 2015-04-13 21:57 mediaPla
文件 22976 2015-04-13 21:57 mediaPla
文件 56768 2015-04-13 21:57 mediaPla
文件 2158528 2015-04-13 21:57 mediaPla
文件 720832 2015-04-13 21:58 mediaPla
文件 52672 2015-04-13 21:57 mediaPla
文件 534976 2015-04-13 21:57 mediaPla
文件 29632 2015-04-13 21:57 mediaPla
............此处省略751个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)