| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 11212 人关注过本帖, 1 人收藏
标题:C#视频播放器,非media Player插件
取消只看楼主 加入收藏
sndnnlfhvk
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-9-25
结帖率:0
收藏(1)
已结贴  问题点数:20 回复次数:0 
C#视频播放器,非media Player插件
看来论坛里面的非media player插件音乐播放器,我也写了个视频播放的。代码如下,用directX
程序代码:
using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Microsoft.DirectX;
using Microsoft.DirectX.AudioVideoPlayback;
namespace VideoPlayer
{
    public partial class MainForm : Form
    {
        private Video video = null;

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
           
        }

        private void btnView_Click(object sender, EventArgs e)
        {
         
                OpenFileDialog openDlg = new OpenFileDialog();
                openDlg.Filter="视频文件(*.wmv;*.avi)|*.wmv;*.avi;";

                if (openDlg.ShowDialog() == DialogResult.OK)
                {
                    if (this.video != null)
                    {
                        if (this.video.Playing)
                        {
                            this.video.Stop();

                          
                        }
                    }

                    this.lblFileName.Text = openDlg.FileName;
                    this.video = new Video(openDlg.FileName);
                    int width = this.panPlayOwner.Width;
                    int height = this.panPlayOwner.Height;
                   
                    this.video.Owner = this.panPlayOwner;
                    this.video.Owner.Width = width;
                    this.video.Owner.Height = height;
                    this.video.Play();

                   
                }
           
        }

        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (this.video != null)
            {
                if (this.video.Playing)
                {
                    this.video.Stop();
                }
                this.video.Play();
            }
        }

        private void btnPause_Click(object sender, EventArgs e)
        {
            if (this.video != null)
            {
                if (this.video.Playing)
                {
                    this.video.Pause();
                }
            }
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            if (this.video != null)
            {
                if (this.video.Playing)
                {
                    this.video.Stop();
                }
            }
        }

        //区域大小改变
        private void panPlayOwner_Resize(object sender, EventArgs e)
        {
            int width = this.panPlayOwner.Width;
            int height = this.panPlayOwner.Height;

            if (this.video != null)
            {
                this.video.Owner.Width = width;
                this.video.Owner.Height = height;
            }
        }

        private void btnFullScreen_Click(object sender, EventArgs e)
        {
            if (this.video != null)
            {
                this.video.Fullscreen = true;
            }
        }

        //退出全屏
        private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Escape)
            {
                if (this.video != null)
                {
                    if (this.video.Fullscreen == true)
                    {
                        this.video.Fullscreen = false;
                    }[local]1[/local]
                }

            }
        }

        private void panPlayOwner_DoubleClick(object sender, EventArgs e)
        {
            if (this.video != null)
            {
                if (this.video.Fullscreen)
                {
                    this.video.Fullscreen = false;
                }
            }
        }

  
    }
}




VideoPlayer.rar (125.66 KB)
搜索更多相关主题的帖子: Player 视频播放器 media 插件 
2010-11-05 10:16
快速回复:C#视频播放器,非media Player插件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028284 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved