C#学习11
来源:互联网 发布:mac 修图软件推荐 编辑:程序博客网 时间:2024/06/05 10:44
C#学习11
使用Windows窗体应用程序,基于Windows Media Player组件写一个简单的播放器,功能比较简陋,通过打开文件按钮来选取音乐所在的地址,还有4个按钮,分别是:播放,结束,暂停/继续,歌曲信息
添加AxWindowsMediaPlayer控件的方法:在”工具箱”中单击右键,选择”选择项”菜单,打开”选择工具箱项”窗口,选择”COM”组件”标签,在列表中找到并勾选”Windows Media Player”组件,单击”确定”按钮。将该组件添加到指定的工具箱选项卡中,然后在工具箱里面找 Windows Media Player 控件,拉到form里面即可
OpenFileDialog控件也许注意
赋个截图,按暂停按钮时停止播放,再按一次就继续播放
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 cam{ public partial class Cambridge : Form { public Cambridge() { InitializeComponent(); } private void ButPlay_Click(object sender, EventArgs e) //加载多媒体文件 { this.axWindowsMediaPlayer1.URL = this.optFile.FileName; } private void ButOpen_Click(object sender, EventArgs e) { this.optFile.ShowDialog(); this.axWindowsMediaPlayer1.newMedia(this.optFile.FileName); } private void ButStop_Click(object sender, EventArgs e) //停止 { this.axWindowsMediaPlayer1.Ctlcontrols.stop(); } private void ButPause_Click(object sender, EventArgs e) { if (this.ButPause.Text == "暂停") //暂停播放 { this.axWindowsMediaPlayer1.Ctlcontrols.pause(); this.ButPause.Text = "继续"; } else { this.axWindowsMediaPlayer1.Ctlcontrols.play();//继续播放 this.ButPause.Text = "暂停"; } } private WMPLib.WindowsMediaPlayerClass c;//媒体对象 private WMPLib.IWMPMedia m; //建立媒体播放列表对象 private void ButInfo_Click(object sender, EventArgs e) { if (this.optFile.FileName != "optFile") //实例化WindowsMediaPlayerClass类的对象 { c = new WMPLib.WindowsMediaPlayerClass(); m = c.newMedia(this.optFile.FileName); MessageBox.Show("歌手名:" + m.getItemInfo("Author") + "\r\n" + "歌名:" + m.getItemInfo("Title")); } } }}
- C#学习日志(11)
- C#学习11
- 黑马程序员 c#学习11
- C#学习笔记11:窗口
- C#学习----C#变量
- C#学习---C#简介
- 【C#学习】C#基础
- 学习C#
- C#学习:
- c#学习
- C#学习
- C#学习
- C#学习
- C#学习
- 学习c#
- C#学习
- 学习c#
- C#学习
- Eclipse+PyDev离线配置Python开发环境
- Oracle数据库报bug,表或试图不存在,表名中包含空格
- windows程序设计 绘图模式--SetROP2
- 一次谷歌面试趣事
- 如何把连续视频帧转为视频的matlab代码
- C#学习11
- VMWare8运行Mac OS Lion时安装VMTools的问题
- HDU 4277 - USACO ORZ
- mingw下编译mplayer支持rtsp播放
- Linux CPU位数&操作系统位数
- 如何在C#应用程序和DLL中使用消息
- 根文件系统的启动及配置linuxrc - linuxrc又来以及解释
- Omap 3530 SDRAM 控制器初始化的一些思考
- 用一生去成长——我对《美丽心灵》的解读