资源简介
C#万能视频播放器(附代码)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace vlc.net
{
public partial class Form1 : Form
{
private VlcPlayer vlc_player_;
private bool is_playinig_;
public Form1()
{
InitializeComponent();
string pluginPath = System.Environment.CurrentDirectory + “\\plugins\\“;
vlc_player_ = new VlcPlayer(pluginPath);
IntPtr render_wnd = this.panel1.Handle;
vlc_player_.SetRenderWindow((int)render_wnd);
tbVideoTime.Text = “00:00:00/00:00:00“;
is_playinig_ = false;
}
private void btnStart_Click(object sender EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
vlc_player_.PlayFile(ofd.FileName);
trackBar1.SetRange(0 (int)vlc_player_.Duration());
trackBar1.Value = 0;
timer1.Start();
is_playinig_ = true;
}
}
private void btnReset_Click(object sender EventArgs e)
{
if (is_playinig_)
{
vlc_player_.Stop();
trackBar1.Value = 0;
timer1.Stop();
is_playinig_ = false;
}
}
private void timer1_Tick(object sender EventArgs e)
{
if (is_playinig_)
{
if (trackBar1.Value == trackBar1.Maximum)
{
vlc_player_.Stop();
timer1.Stop();
}
else
{
trackBar1.Value = trackBar1.Value + 1;
tbVideoTime.Text = string.Format(“{0}/{1}“
GetTimeString(trackBar1.Value)
GetTimeString(trackBar1.Maximum));
}
}
}
private string GetTimeString(int val)
{
int hour = val / 3600;
val %= 3600;
int minute = val / 60;
int second = val % 60;
return string.Format(“{0:00}:{1:00}:{2:00}“ hour minute second);
}
private void trackBar1_Scroll(object sender EventArgs e)
{
if (is_playinig_)
{
vlc_player_.SetPlayTime(trackBar1.Value);
trackBar1.Value = (int)vlc_player_.GetPlayTime();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 117 2012-10-16 13:07 vlc.net\app.config
文件 102400 2011-04-12 08:45 vlc.net\bin\Debug\libvlc.dll
文件 2279936 2011-04-12 08:45 vlc.net\bin\Debug\libvlccore.dll
文件 65536 2011-06-07 07:29 vlc.net\bin\Debug\plugins\liba52tofloat32_plugin.dll
文件 30720 2011-06-07 07:29 vlc.net\bin\Debug\plugins\liba52tospdif_plugin.dll
文件 36352 2011-06-07 07:29 vlc.net\bin\Debug\plugins\liba52_plugin.dll
文件 31232 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_attachment_plugin.dll
文件 90112 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_bd_plugin.dll
文件 33792 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_fake_plugin.dll
文件 41472 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_ftp_plugin.dll
文件 88064 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_http_plugin.dll
文件 44544 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_imem_plugin.dll
文件 75776 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_mms_plugin.dll
文件 30720 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_output_dummy_plugin.dll
文件 32256 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_output_file_plugin.dll
文件 35840 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_output_http_plugin.dll
文件 394240 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_output_shout_plugin.dll
文件 36352 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_output_udp_plugin.dll
文件 70144 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_realrtsp_plugin.dll
文件 34304 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_smb_plugin.dll
文件 31744 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_tcp_plugin.dll
文件 32768 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaccess_udp_plugin.dll
文件 49152 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libadjust_plugin.dll
文件 38912 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libadpcm_plugin.dll
文件 33280 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaes3_plugin.dll
文件 33792 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaiff_plugin.dll
文件 33280 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libalphamask_plugin.dll
文件 46592 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaout_directx_plugin.dll
文件 34816 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaout_file_plugin.dll
文件 267264 2011-06-07 07:29 vlc.net\bin\Debug\plugins\libaout_sdl_plugin.dll
............此处省略289个文件信息
- 上一篇:C#线程参考手册
- 下一篇:C#调用摄像头实现拍照和录像
评论
共有 条评论