using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VideoGoogle
{
    //选择菜单中的“工具”--“自定义工具箱”,打开“自定义工具箱”窗口,在“COM 组件”中选择“Windows Media Player”播放器和
    //“Shockwave Flash Object”flash播放器
    
    public partial class Form1 : Form
    {
        private static string PathBase = System.AppDomain.CurrentDomain.BaseDirectory;//目录

public Form1()
        {
            InitializeComponent();
        }

private void Form1_Load(object sender, EventArgs e)
        {
            //this.axWindowsMediaPlayer1.uiMode = "none";//右键axWindowsMediaPlayer1--属性--常规--控件布局--选择模式--None
            this.tbarVolume.Minimum = 0;                                               //設定音量調整Bar最小值為最小音量值(0)
            this.tbarVolume.Maximum = 100;                                             //設定音量調整Bar最大值為最大音量值(100)
            this.tbarVolume.Value = this.axWindowsMediaPlayer1.settings.volume;
        }

//打开
        private void button5_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            //设置为可以打开多个文件
            openFileDialog.Multiselect = true;
            //设置打开文件格式
            openFileDialog.Filter = "Mp3文件|*.mp3|Wav文件|*.wav|Wma文件|*.wma|Wmv文件|*.wmv|所有格式|*.*";
            //判断是否单击确定按钮
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //建立播放列表,名字为aa
                axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.newPlaylist("aa", "");
                //遍历打开的集合
                foreach (string fn in openFileDialog.FileNames)
                {
                    //添加播放列表
                    axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(fn));
                }
            }
            //播放
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

//播放视频
        private void button1_Click(object sender, EventArgs e)
        {
            string Path = PathBase + "航架2.mpg";
            this.axWindowsMediaPlayer1.URL = Path;
            this.axWindowsMediaPlayer1.Ctlcontrols.play();  
        }

//播放MP3
        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.Filter = "mp3文件|*.mp3";
            if (DialogResult.OK == openFile.ShowDialog())
            {
                axWindowsMediaPlayer1.URL = openFile.FileName;
            }
        }

//设置
        private void button6_Click(object sender, EventArgs e)
        {
            string Duration = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Duration");//持续时间(秒)
            string Title = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Title");//媒体标题
            string Author = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Author");//艺术家
            string Copyright = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Copyright");//版权信息
            string Description = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("Description");//媒体内容描述
            string FileSize = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("FileSize");//文件大小
            string FileType = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("FileType");//文件类型
            string sourceURL = this.axWindowsMediaPlayer1.currentMedia.getItemInfo("sourceURL");//原始地址
            MessageBox.Show("持续时间:"+Duration+"||"+"媒体标题:"+Title+"||"+"艺术家:"+Author+"||"+"版权信息:"+Copyright+"||"+"媒体内容描述:"+Description+"||"+"文件大小:"+FileSize+"||"+"文件类型:"+FileType+"||"+"原始地址:"+sourceURL);

string name = this.axWindowsMediaPlayer1.currentMedia.name;
            string url = this.axWindowsMediaPlayer1.currentMedia.sourceURL;

//设置
            //this.axWindowsMediaPlayer1.currentMedia.setItemInfo("Title", "航架");

this.axWindowsMediaPlayer1.settings.balance = 0;//表示媒体播放的声道设置,0表示均衡,-1和1表示左右声道
            double rate = this.axWindowsMediaPlayer1.settings.rate;//播放速率,一般乘以16后再显示kbps单位.
            //this.axWindowsMediaPlayer1.currentMedia.setItemInfo("rate", "2");
        }

//打开Flash
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofDialog = new OpenFileDialog();
            ofDialog.AddExtension = true;
            ofDialog.CheckFileExists = true;
            ofDialog.CheckPathExists = true;
            ofDialog.Filter = "Flash文件(*.swf)|*.swf|所有文件(*.*)|*.*"; ;// "swf 文件 (*.swf)|*.swf|所有文件 (*.*)|*.*";
            ofDialog.DefaultExt = "mp3";
            if (ofDialog.ShowDialog() == DialogResult.OK)
            {
                this.axShockwaveFlash1.Movie = ofDialog.FileName;
            }

//==========================================
            //openFileDialog1.Filter = "Flash文件(*.swf)|*.swf|所有文件(*.*)|*.*";
            //if (openFileDialog1.ShowDialog() == DialogResult.OK)
            //{
            //    string MyFileName = openFileDialog1.FileName;
            //    this.axShockwaveFlash1.Movie = MyFileName;
            //}
        }

//Flash
        private void button3_Click(object sender, EventArgs e)
        {
            this.axShockwaveFlash1.Stop();//暂停播放
            this.axShockwaveFlash1.Rewind();//播放第一帧
            this.axShockwaveFlash1.Back();//播放上一帧
            this.axShockwaveFlash1.Forward();//开始播放
            this.axShockwaveFlash1.Rewind();//播放下一帧
            this.axShockwaveFlash1.Play();//播放下一帧
        }

//play
        private void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

//pause
        private void pauseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

//stop
        private void stopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.stop();
        }

//open
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            //设置为可以打开多个文件
            openFileDialog.Multiselect = true;
            //设置打开文件格式
            openFileDialog.Filter = "Mp3文件|*.mp3|Wav文件|*.wav|Wma文件|*.wma|Wmv文件|*.wmv|所有格式|*.*";
            //判断是否单击确定按钮
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //建立播放列表,名字为aa
                axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.newPlaylist("aa", "");
                //遍历打开的集合
                foreach (string fn in openFileDialog.FileNames)
                {
                    //添加播放列表
                    axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(fn));
                }
            }
            //播放
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

//exit
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

//上一个
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.previous();
        }

//播放
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

//下一个
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.next();
        }

//暂停
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

//停止
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.stop();
        }

//进度
        private void timer1_Tick(object sender, EventArgs e)
        {
            double total=0.0d;
            if (this.axWindowsMediaPlayer1.currentMedia != null)
            {
                total = Math.Ceiling(this.axWindowsMediaPlayer1.currentMedia.duration);

this.tbarPlayLoaction.Maximum = (int)this.axWindowsMediaPlayer1.currentMedia.duration;//設定撥放位置調整Bar最大值                    
            }
            double cur = Math.Floor(this.axWindowsMediaPlayer1.Ctlcontrols.currentPosition);
            if (total != 0)
            {
                this.progressBar1.Value = (int)(cur / total *100);
                this.label1.Text = cur.ToString()+"s" + "/" + total.ToString()+"s";

this.tbarPlayLoaction.Value = (int)(cur / total * total);
            }

//---------------------------------
            ////循环播放
            //if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsStopped)
            //{
            //    axWindowsMediaPlayer1.Ctlcontrols.play();
            //}
        }

//快进
        private void button7_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.Ctlcontrols.fastForward();
        }

//快退
        private void button8_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.Ctlcontrols.fastReverse();
        }

//自动播放
        private void autoStartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.autoStartToolStripMenuItem.Checked)
            {
                this.axWindowsMediaPlayer1.settings.autoStart = true;
            }
        }

//播放
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.Ctlcontrols.play();
        }

//暂停
        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

//显示当前音量
        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            int volume=this.axWindowsMediaPlayer1.settings.volume;
            MessageBox.Show("音量:"+volume.ToString());

//this.axWindowsMediaPlayer1.currentMedia.setItemInfo("volume", "60");     
        }

//改变音量大小
        private void tbarVolume_Scroll(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.settings.volume = this.tbarVolume.Value;      //改變音量大小
        }

//音量打下++
        private void button9_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.settings.volume += 1;       //音量大小+1
            int volume = this.axWindowsMediaPlayer1.settings.volume;
            this.tbarVolume.Value = volume;
        }

//音量大小--
        private void button10_Click(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.settings.volume -= 1;       //音量大小-1
            int volume = this.axWindowsMediaPlayer1.settings.volume;
            this.tbarVolume.Value = volume;
        }

//播放位置
        private void tbarPlayLoaction_Scroll(object sender, EventArgs e)
        {
            this.axWindowsMediaPlayer1.Ctlcontrols.currentPosition = tbarPlayLoaction.Value;
        }

//循环播放
        private void loopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.loopToolStripMenuItem.Checked)
            {
                ////第一种:
                //if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsStopped)
                //{
                //    axWindowsMediaPlayer1.Ctlcontrols.play();
                //}

////第二种:
                axWindowsMediaPlayer1.settings.setMode("loop", true);
            }
        }

}
}

C# axWindowsMediaPlayer制作播放器的更多相关文章

  1. 原生js制作播放器

    以前 就想做一个播放器,一直没狠下心来,今天终于狠下心来,把这个做出来了(因为有点无聊) 做这个播放器  也百度了一下, 你叫我做,我肯定做不出来, 就算用jquery  我也做不出来. 以前也用过a ...

  2. 使用react native制作的一款网络音乐播放器

    使用react native制作的一款网络音乐播放器 基于第三方库 react-native-video设计"react-native-video": "^1.0.0&q ...

  3. QT制作一个图片播放器

    前言:使用qt制作了一个简单的图片播放器,可以播放gif.png等格式图片 先来看看播放器的功能(当然是很简陋的,没有很深入的设计): 1.点击图片列表中图片进行播放. 2.自动播放,播放的图片的间隔 ...

  4. JavaCV 学习(二):使用 JavaCV + FFmpeg 制作拉流播放器

    一.前言 在 Android 音视频开发学习思路 中,我们不断的学习和了解音视频相关的知识,随着知识点不断的学习,我们现在应该做的事情,就是将知识点不断的串联起来.这样才能得到更深层次的领悟.通过整理 ...

  5. HTML+纯JS制作音乐播放器

    该篇文章会教你通过JavaScript制作一个简单的音乐播放器.包括播放.暂停.上一曲和下一曲. 阅读本文章你需要对HTML.CSS和Javascript有基本的了解. 话不多说,先上图. emmm. ...

  6. 使用 原生js 制作插件 (javaScript音乐播放器)

    1.引用页面 index.html <!DOCTYPE html> <html lang="en"> <head> <meta chars ...

  7. 使用AVPlayer制作一个播放器

    代码地址如下:http://www.demodashi.com/demo/11685.html AVPlayer 是一个强大的视频播放器,可以播放多种格式的视频,缺点是没有控制界面,需要自己去实现. ...

  8. Swift - 制作一个在线流媒体音乐播放器(使用StreamingKit库)

    在之前的文章中,我介绍了如何使用 AVPlayer 制作一个简单的音乐播放器(点击查看1.点击查看2).虽然这个播放器也可以播放网络音频,但其实际上是将音频文件下载到本地后再播放的. 本文演示如何使用 ...

  9. 使用LM386制作Arduino音乐播放器

    在我们的项目中添加声音或音乐总是会使其看起来更酷一些,听上去更有吸引力.特别是如果您使用的是Arduino开发板,并且有很多空余的引脚,只需要添加一个SD卡模块和一个普通的扬声器即可轻松添加音效.在本 ...

随机推荐

  1. windbg*****************************TBD

    achieve structure from a simple address Dt address know pending IRP in a module !thread xxxxxx到底能提供哪 ...

  2. Windows下的Memcache安装与Java部署

    Windows下的Memcache安装: 1. 下载memcached的windows稳定版,解压放某个盘下面,比如在c:\memcached 2. 在终端(也即cmd命令界面)下输入 ‘c:\mem ...

  3. C# + ArcEngine 常用方法(不定时更新)

    1.Arcengine调用GP服务,抛出异常方法 object sev = null; try { Application.DoEvents(); gp.Execute(gpBuildPyramids ...

  4. 利用FFT来进行字符串匹配

    给定串A和串B,A由26个小写字母构成,B由?和26个小写字母构成 ?可以和任意字符匹配 求A中出现了多少次B 这里可以使用fft做法,定义向量A和向量B 然后求A和rev(B)的卷积结果C C的第i ...

  5. Codeforce 721C DP+DAG拓扑序

    题意 在一个DAG上,从顶点1走到顶点n,路径上需要消费时间,求在限定时间内从1到n经过城市最多的一条路径 我的做法和题解差不多,不过最近可能看primer看多了,写得比较复杂和结构化 自己做了一些小 ...

  6. Problem Collection I 位运算

    XOR ARC 092B CF 959E xor-MST CF 959F

  7. [洛谷P2210]Haywire

    题目大意:有$n(n\leqslant12)$个数,每个数和其他三个数连边,求一个排列,使得边的长度最小 题解:状压$DP$,$f_{i,j}$表示当前确定的数状态为$i$,有$j$条边起点被确定终点 ...

  8. mybatis的注解功能

    一.mybatis 简单注解 关键注解词 : @Insert : 插入sql , 和xml insert sql语法完全一样 @Select : 查询sql, 和xml select sql语法完全一 ...

  9. zigbee ---- profile 和 cluster

    在zigbee规范中,引入了profile, cluster的概念.具体说来,假设规范一个profile(可以理解成一套规定),这个profile用来规范智能家居领域的相关产品都要满足那些要求,那么h ...

  10. 随机洗牌算法Knuth Shuffle和错排公式

    Knuth随机洗牌算法:譬如现在有54张牌,如何洗牌才能保证随机性.可以这么考虑,从最末尾一张牌开始洗,对于每一张牌,编号在该牌前面的牌中任意一张选一张和当前牌进行交换,直至洗到第一张牌为止.参考代码 ...