在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → winform 播放本地视频源码下载(Interop.WMPLib)

winform 播放本地视频源码下载(Interop.WMPLib)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:4.50M
  • 下载次数:68
  • 浏览次数:737
  • 发布时间:2016-12-12
  • 实例类别:C#语言基础
  • 发 布 人:zdfbfr
  • 文件格式:.rar
  • 所需积分: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
         */
    }
}

标签: 播放

实例下载地址

winform 播放本地视频源码下载(Interop.WMPLib)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警