如何让SoundPlayer播放完一首之后自动播下一首?

解决方案 »

  1.   

    看来SoundPlayer没有这个功能,SoundPlayer的属性、方法和事件里都找不到一个可以判断播放完毕的一个标志。
      

  2.   

    好像有哦?SoundPlayer player = new SoundPlayer("file.wav");
    player.Play();
    player.Stop();
      

  3.   

    没有取得播放进度的属性
    换 MediaPlayer 
      

  4.   

    2楼的朋友没有明白我的意思,player.Stop()是你主动停止,并不是获取播放进度.
      

  5.   

    貌似又一次没仔细看楼主要的。
    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");
            }
        }
    }
      

  6.   

    文字打印顺序错了。修改一下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);
                        }
                        Console.WriteLine("Playing complete");
                    }).Start();            
            }
        }
    }
      

  7.   

    lz去查mciSendString api,这个api还可以播放mp3呢,其中有方法获得播放的进度,具体百度,google
    参考