编写这个播放器,遇到很多问题,比如目前只实现了wav音频文件的播放,而对于这个图中中间所标注的按钮

不能实现让其暂停的功能,同时当点击的时候,让其文本变为"▷",对于这部分功能不知道选定该按钮时的属性是

如何,所以还需继续完善

播放器代码
 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
using System.IO; namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ }
List<string> listSongs = new List<string>();//定义存储歌名的路径泛型变量
private void button5_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "请选择音频文件";
ofd.InitialDirectory =@"F:\wav_music";
ofd.Filter="音频文件|*.wav|所有文件|*.*";
ofd.Multiselect=true;//多选设置
ofd.ShowDialog();
string[] path = ofd.FileNames;//获取音频文件的全路径
for (int i = ; i < path.Length; i++)
{
listBox1.Items.Add(Path.GetFileName(path[i]));//将获取到的文件路径截取文件名并添加到listbox中
listSongs.Add(path[i]);//将路径添加到list集合当中 } }
/// <summary>
/// 双击播放音乐方法。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param> private void listBox1_DoubleClick(object sender, EventArgs e)
{
SoundPlayer sp = new SoundPlayer();//
sp.SoundLocation = listSongs[listBox1.SelectedIndex];
sp.Play();
}
/// <summary>
/// 播放下一首
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param> private void button4_Click(object sender, EventArgs e)
{
//获取当前所选定的音乐项
int index = listBox1.SelectedIndex;
index++;
SoundPlayer sp = new SoundPlayer();
if (index ==listSongs.Count)
{ index = ;
}
listBox1.SelectedIndex = index;//将索引重新赋值给listbox选定。
sp.SoundLocation = listSongs[index];
sp.Play(); }
/// <summary>
/// 播放上一首
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param> private void button2_Click(object sender, EventArgs e)
{
//获取当前所选定的音乐项
int index = listBox1.SelectedIndex;
index--;
SoundPlayer sp = new SoundPlayer();
if (index == )
{
index = listSongs.Count - ;
}
listBox1.SelectedIndex = index;
sp.SoundLocation = listSongs[index];
sp.Play(); }
}
}

最新文章

  1. cocoapods Analyzing dependencies 问题的解决方案
  2. 冲刺一 (Day 2)
  3. CF570D:Tree Requests
  4. 新建Oracle数据库时,提示使用database control配置数据库时,要求在当前oracle主目录中配置监听程序
  5. Jquery表单提交方式
  6. 主机找不到vmnet1和vmnet8
  7. 你真的会玩SQL吗?实用函数方汇总
  8. Apple Watch 使用体验
  9. ASP.NET MVC(一) 什么是Razor
  10. ajax验证用户名和找回密码参考
  11. INT_MAX (2147483647) 和INT_MIN (-2147483648)溢出
  12. OpenShift实战(三):OpenShift持久化存储Redis
  13. 【剑道】日常练习相关Q&amp;A 整理
  14. final,finally和 finalize的区别
  15. 分享八:特殊的mysql函数
  16. Nmap 扫描
  17. 快速理解Event事件
  18. POJ Air Raid 【DAG的最小不相交路径覆盖】
  19. javascript 例外处理Try{}catch(e){}
  20. Systems Performance: Enterprise and the Cloud 读书笔记系列

热门文章

  1. Fedora下依赖库的解决
  2. MySQL 应用优化
  3. 第二篇 基于.net搭建热插拔式web框架(沙箱的构建)
  4. Java transient 关键字
  5. 【Python网络爬虫二】使用urllib2抓去网页内容
  6. composer 报错:Your requirements could not be resolved to an installable set of packages 解决方法
  7. RBAC中 permission , role, rule 的理解
  8. 数独 JAVA实现
  9. 实现放大转场动画 from cocoachina
  10. log4j使用总结