System.Media.SoundPlayer, Playing more than 1 sound?

那年仲夏 提交于 2019-12-11 10:06:27

问题


Is there a way to play more than one sound while let's say the background music is going?

The way I have it is:

    public static void PlaySound(string filename)
    {
        SoundPlayer player = new SoundPlayer();
        player.SoundLocation = filename;
        player.Play();
    }

Which will play one sound, but using the same "PlaySound" it will basically stop the last sound played and just start a new thread playing the new sound. Is there a way to actually stop this and play more than one sound(s)?


回答1:


Take a look at:

Play multiple sounds using SoundPlayer n-c-net

Note the solution with mciSendString at the bottom.



来源:https://stackoverflow.com/questions/6820588/system-media-soundplayer-playing-more-than-1-sound

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!