六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 47|回复: 0

c# winform 用pictureBox播放视频,打开文件对话框,openFileDialog

[复制链接]

升级  61.3%

726

主题

726

主题

726

主题

探花

Rank: 6Rank: 6

积分
2226
 楼主| 发表于 2013-1-27 05:13:10 | 显示全部楼层 |阅读模式
源码可在这下载,把swf改为rar解压
videotest.swf
首先拖拽到Form上的东西
pictureBox,button,和openFileDialogbutton的单击事件:private void button1_Click(object sender, EventArgs e)        {            this.openFileDialog1.ShowDialog();            video.VideoName = this.openFileDialog1.FileName;            video.PlayVideo(video.VideoName, this.pictureBox1);        } 设置openFileDialog的Filter属性,要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所有文件(*.*)||*.*",这个格式为,1|2|3|4|5|6,单数为显示,双数为执行,比如“文本文件(*.txt)|*.txt”,这样打开了对话框后就显示出文本文件(*.txt),而后边的*.txt则会把.txt的文件显示
这个播放功能的全部代码如下


using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace videotest{    public partial class Form1 : Form    {        Media.VideoPlay video = new Media.VideoPlay();        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            this.openFileDialog1.ShowDialog();            video.VideoName = this.openFileDialog1.FileName;            video.PlayVideo(video.VideoName, this.pictureBox1);        }    }} 
需要注意的是要引入一个第3方的Media.dll

源码可在这下载,把swf改为rar解压
videotest.swf
 
黑色头发  http://heisetoufa.iteye.com
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表