如何让SoundPlayer播放完一首之后自动播下一首?
解决方案 »
- C#操作EXCEL的问题,高手进
- 一道面试题
- 简单的问题,送分了
- 八百里加急快报.................急急急急急急....
- vs2005 c# 如何套打EXCEL
- 为什么我一用lucene.net类库时,建索引的时候一下子,就CPU资源就占用100%,难道类库,有问题吗?我用的是最新的lucene.net类库v1.3final版的
- C#如何在小数区间如(0,0.65298426587...)间产生一个随机数
- 要学习.net remoting 用什么书比较好?
- 哪位大侠推荐基本免费的C#电子书籍,最好是.pdf的。
- 为什么 .net beta2中找不到 Sytem.Data.SQL namespace
- C# 串口通信问题
- datagridview 显示几行空行
player.Play();
player.Stop();
换 MediaPlayer
SoundPlayer同步播放,创建线程来做。using System;
using System.Collections.Generic;
using System.Media;
using System.Threading;
namespace ConsoleApplication1
{
public partial class Program
{
static void Main(string[] args)
{
TestPlayList();
Console.ReadKey();
} private static void TestPlayList()
{
List<string> playList = new List<string>();
playList.Add("1.wav");
playList.Add("2.wav");
SoundPlayer player = new SoundPlayer();
new Thread((ThreadStart)delegate
{
while (playList.Count>0)
{
Console.WriteLine("Playing " + playList[0]);
player.SoundLocation = playList[0];
player.PlaySync();
playList.RemoveAt(0);
}
}).Start();
Console.WriteLine("Playing complete");
}
}
}
using System.Collections.Generic;
using System.Media;
using System.Threading;
namespace ConsoleApplication1
{
public partial class Program
{
static void Main(string[] args)
{
TestPlayList();
Console.ReadKey();
} private static void TestPlayList()
{
List<string> playList = new List<string>();
playList.Add("1.wav");
playList.Add("2.wav");
SoundPlayer player = new SoundPlayer();
new Thread((ThreadStart)delegate
{
while (playList.Count>0)
{
Console.WriteLine("Playing " + playList[0]);
player.SoundLocation = playList[0];
player.PlaySync();
playList.RemoveAt(0);
}
Console.WriteLine("Playing complete");
}).Start();
}
}
}
参考