0

I want to create a button, when the user click the button, the application can play music (played in embedded way or external way are both ok) I am just a rookie on c# and only know how to create a button Anyone know how to code it?

    private void musicbutton_Click(object sender, EventArgs e)
    {

    }  
user1994617
  • 135
  • 1
  • 4
  • 14

2 Answers2

1

if the sound file is wave file, you can go for the following.

My.Computer.Audio.Play("wave.wav", AudioPlayMode.WaitToComplete)

and you will find more on search engines.

jparthj
  • 1,606
  • 3
  • 20
  • 44
0

This question has already been answered here: How to play mp3 files in C#?. You can use @jparthj's solution too, but add a reference to "Microsoft.VisualBasic.dll" as specified here: http://msdn.microsoft.com/en-us/library/cf1shcah%28v=vs.90%29.aspx

Community
  • 1
  • 1
Matt
  • 6,787
  • 11
  • 65
  • 112
  • Thanks for your ans, I hv just added a reference "Microsoft.VisualBasic.dll" and typed using Microsoft.VisualBasic; But the MY. is still not work. DO you know the reason? – user1994617 Mar 03 '13 at 07:57
  • "Microsoft.DirectX.AudioVideoPlayback.dll" simply try adding this reference to your project. – jparthj Mar 03 '13 at 08:34
  • Thanks for your reply again :) I have added Microsoft.DirectX.AudioVideoPlayback.dll with the code using Microsoft.DirectX.AudioVideoPlayback; However, the "my" is still undefined I am finding the reason, may u give me some opinion :)? – user1994617 Mar 03 '13 at 11:24