基本信息
源码名称:winform 播放本地视频源码下载(Interop.WMPLib)
源码大小:4.50M
文件格式:.rar
开发语言:C#
更新时间:2016-12-12
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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 DemandVideo1
{
public partial class Index : Form
{
private String url = @"D:\\CSharp代码(未整理)\\S1作业\\KTV项目-自己\\KTV\\资源\\song\\"; //绝对路径
private OpenFileDialog openFile = new OpenFileDialog();
private Dictionary<int, String> d = new Dictionary<int, string>();
private String activeUrl = "";
public Index()
{
InitializeComponent();
initList();
}
private void wmp_Enter(object sender, EventArgs e)
{
this.listPan.Visible = false;
}
private void Index_Load(object sender, EventArgs e)
{
}
//打开文件按钮
private void clickBtn_Click(object sender, EventArgs e)
{
openFile.ShowDialog();
this.picPan.Visible = false;
this.wmp.URL = openFile.FileName;
activeUrl = openFile.FileName;
this.Text = "点播视频 " openFile.FileName.Split('.')[0];
this.playBtn.Text = "暂停";
}
//播放、暂停按钮
private void playBtn_Click(object sender, EventArgs e)
{
//this.wmp.URL = openFile.FileName;
Button btn = (Button)sender;
if (btn.Text.Equals("播放"))
{
this.wmp.URL = activeUrl;
btn.Text = "停止";
this.picPan.Visible = false;
}
else
{
this.wmp.close();
this.picPan.Visible = true;
this.listPan.Visible = false;
btn.Text = "播放";
}
}
//文件列表按钮
private void listBtn_Click(object sender, EventArgs e)
{
this.listPan.Visible = !this.listPan.Visible;
//System.Windows.Forms.Button btn1 = new System.Windows.Forms.Button();
/*this.closeBtn.Location = new System.Drawing.Point(693, 457);
this.closeBtn.Name = "closeBtn";
this.closeBtn.Size = new System.Drawing.Size(75, 23);
this.closeBtn.TabIndex = 3;
this.closeBtn.Text = "停止";
this.closeBtn.UseVisualStyleBackColor = true;
this.closeBtn.Click = new System.EventHandler(this.closeBtn_Click);*/
}
private void initList()
{
/*for (int i = 0; i < 35; i )
{
Button label = new Button();
label.Location = new System.Drawing.Point(0, 23 * i);
label.Size = new System.Drawing.Size(75, 23);
label.BackColor = System.Drawing.Color.Blue;
label.Text = "kkkkkkkk" i;
//label.TabIndex = 10 i;
label.Click = new System.EventHandler(this.label_Click);
this.listPan.Controls.Add(label);
}*/
this.listPan.AutoScroll = true;
//禁止窗体放大缩小
this.MinimizeBox = true;
this.MaximizeBox = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
//this.listPan.MouseLeave = new System.EventHandler(this.listPan_MouseLeave);
//this.picPan.MouseMove = new System.EventHandler(this.wmp_Enter);
DirectoryInfo di = new DirectoryInfo(url);
int i = 0;
try
{
foreach (FileInfo f in di.GetFiles())
{
Label label = new Label();
label.Location = new System.Drawing.Point(10, 23 * i 10);
label.Size = new System.Drawing.Size(75, 23);
label.BackColor = System.Drawing.Color.Blue;
label.ForeColor = System.Drawing.Color.White;
label.Text = f.Name;
//label.TabIndex = 10 i;
label.Click = new System.EventHandler(this.label_Click);
this.listPan.Controls.Add(label);
}
}
catch (Exception ex)
{
}
}
private void label_Click(object sender, EventArgs e)
{
//this.closeBtn.Text = ((Label)this.Controls["label"]).Text;
//this.closeBtn.Text = ((Button)sender).Text;
activeUrl = url ((Label)sender).Text;
this.wmp.URL = url ((Label)sender).Text;
this.playBtn.Text = "暂停";
this.Text = "点播视频 " ((Label)sender).Text.Split('.')[0];
this.picPan.Visible = false;
}
/*
URL:String; 指定媒体位置,本机或网络地址
uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible
playState:integer; 播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪
enableContextMenu:Boolean; 启用/禁用右键菜单
fullScreen:boolean; 是否全屏显示
[controls] wmp.controls //播放器基本控制
controls.play; 播放
controls.pause; 暂停
controls.stop; 停止
controls.currentPosition:double; 当前进度
controls.currentPositionString:string; 当前进度,字符串格式。如“00:23”
controls.fastForward; 快进
controls.fastReverse; 快退
controls.next; 下一曲
controls.previous; 上一曲
[settings] wmp.settings //播放器基本设置
settings.volume:integer; 音量,0-100
settings.autoStart:Boolean; 是否自动播放
settings.mute:Boolean; 是否静音
settings.playCount:integer; 播放次数
[currentMedia] wmp.currentMedia //当前媒体属性
currentMedia.duration:double; 媒体总长度
currentMedia.durationString:string; 媒体总长度,字符串格式。如“03:24”
currentMedia.getItemInfo(const string); 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述,"Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址
currentMedia.setItemInfo(const string); 通过属性名设置媒体信息
currentMedia.name:string; 同 currentMedia.getItemInfo("Title")
[currentPlaylist] wmp.currentPlaylist //当前播放列表属性
currentPlaylist.count:integer; 当前播放列表所包含媒体数
currentPlaylist.Item[integer]; 获取或设置指定项目媒体信息,其子属性同wmp.currentMedia
*/
}
}