初试WindowsMediaPlayer
来源:互联网 发布:lurker间谍软件多少钱 编辑:程序博客网 时间:2024/05/29 04:56
用WindowsMediaPlayer控件写了一个小播放器,只是一个小尝试
首先要添加Windows Media Player到工具箱
右击工具箱->选择项(I)... -> 显示"选择工具箱项" -> COM组件 -> Windows Media Player wmp.dll 添加
然后拖了一个 Windows Media Player控件、两个按钮、一个ListBox。
附:
private void button1_Click(object sender, EventArgs e) { AddMusicToListBox(listBox1); } private void AddMusicToListBox(ListBox lb) { string[] files = GetMusicFiles(); if (files != null && files.Length > 0) { foreach (string file in files) { if (!lb.Items.Contains(file)) { lb.Items.Add(file); } } } } private string[] GetMusicFiles() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true;//设置 选择多个文件 ofd.InitialDirectory = @"G:\MUSIC"; ofd.Filter = "(MP3文件)|*.mp3"; if (ofd.ShowDialog() == DialogResult.OK) { return ofd.FileNames; } else { return null; } } private void listBox1_DoubleClick(object sender, EventArgs e) { axWindowsMediaPlayer1.currentPlaylist.clear(); //MessageBox.Show(listBox1.SelectedItem.ToString()); WMPLib.IWMPMedia song = axWindowsMediaPlayer1.newMedia(listBox1.SelectedItem.ToString()); axWindowsMediaPlayer1.currentPlaylist.appendItem(song); axWindowsMediaPlayer1.Ctlcontrols.play(); } private void button2_Click(object sender, EventArgs e) { RemoveMusicFromListBox(listBox1); } private void RemoveMusicFromListBox(ListBox lb) { lb.Items.Remove(lb.SelectedItem); }
- 初试WindowsMediaPlayer
- 初试
- 初试
- 初试
- 初试
- WMPLib.WindowsMediaPlayer 的用法
- WindowsMediaPlayer 11 控件详解
- WindowsMediaPlayer控件的使用
- WindowsMediaPlayer的用法
- C# WindowsMediaPlayer 播放器
- WindowsMediaPlayer控件的使用
- WindowsMediaPlayer控件的使用
- C#----使用WindowsMediaPlayer
- WindowsMediaPlayer控件的属性
- WindowsMediaPlayer 接口详解
- C#WindowsMediaPlayer的属性
- winform windowsmediaplayer的属性
- C#WindowsMediaPlayer的播放列表
- vs2010 编译 openssl-1.0.1c
- 一个调试的技巧
- PHP编译器 - PCC和PHC
- C# 中文在URL中的编码
- Excel Home 数据透视表初级班(10118班)小结第四课时
- 初试WindowsMediaPlayer
- 如何在ASP.NET中用OWC绘制图表 (1)
- Javascript中正则表达式的全局匹配模式 /g
- java的ArrayList中,数组为什么被transient修饰,这是因为什么原因而设计出来的?
- STL示例04(容器元素的插入)
- 动态数组相关操作
- zoj 3430
- jstl中forEach标签
- c#中的日期格式转化