How to play mp3 files in C#?

前端 未结 7 1008
孤独总比滥情好
孤独总比滥情好 2020-12-09 05:13

I\'m trying to play an MP3 file in C# using this guide: http://www.crowsprogramming.com/archives/58

And I\'m doing everything listed, but I still can\'t play any mus

7条回答
  •  遥遥无期
    2020-12-09 05:51

    I had the same problem and I solved by setting the player as Static, for example:

    public class MiClass(){
    static WMPLib.WindowsMediaPlayer wplayer;
    private void PlayMusic()
        {
            wplayer = new WMPLib.WindowsMediaPlayer();
            wplayer.URL = "c:\shoryuken.mp3";
            wplayer.controls.play();
        }
    }
    

提交回复
热议问题