I am wanting to simply insert a sound/music file into my program, and perhaps make a button function to make it play?
Printable View
I am wanting to simply insert a sound/music file into my program, and perhaps make a button function to make it play?
What have you come across in your searches? And what hasn't worked, that you've tried already?
to embed a .wav file in your app, add the sound file to my.resources then:
vb Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sp As New Media.SoundPlayer sp.Stream = My.Resources.[resourcename] sp.Play() End Sub End Class
I found out a different way as well, and works.
1. Upload a music file to your resources.
2. Input this code where you want it:
And feel free to mess around with the "background" part.Code:My.Computer.Audio.Play(My.Resources.FILENAME, AudioPlayMode.Background)
This does not apply. Like in the other post, if I just gave the OP the solution, instead of leading him to it, he learns nothing.
I'm willing to provide a solution if the OP puts in some effort and shows that he's at least tried to make an attempt at a solution. Again, you're quoting me out of context.
99% of the other members, including the mods, I think, would agree with me. I didn't withhold the information to hinder learning., which is what that quote was getting at. I didn't provide it, so that learning would progress, but it was in the best possible way.