Results 1 to 6 of 6

Thread: How do I put music/sounds inside your program and play them.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2010
    Posts
    16

    How do I put music/sounds inside your program and play them.

    I am wanting to simply insert a sound/music file into my program, and perhaps make a button function to make it play?

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: How do I put music/sounds inside your program and play them.

    What have you come across in your searches? And what hasn't worked, that you've tried already?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: How do I put music/sounds inside your program and play them.

    to embed a .wav file in your app, add the sound file to my.resources then:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         Dim sp As New Media.SoundPlayer
    5.         sp.Stream = My.Resources.[resourcename]
    6.         sp.Play()
    7.     End Sub
    8.  
    9. End Class

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2010
    Posts
    16

    Re: How do I put music/sounds inside your program and play them.

    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:

    Code:
    My.Computer.Audio.Play(My.Resources.FILENAME, AudioPlayMode.Background)
    And feel free to mess around with the "background" part.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Thumbs down Re: How do I put music/sounds inside your program and play them.

    Quote Originally Posted by weirddemon View Post
    What have you come across in your searches? And what hasn't worked, that you've tried already?
    This website, like others, is meant to help people. If you don't share your solution, how can others benefit from that knowledge?

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: How do I put music/sounds inside your program and play them.

    Quote Originally Posted by .paul. View Post
    This website, like others, is meant to help people. If you don't share your solution, how can others benefit from that knowledge?
    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.
    Last edited by weirddemon; Sep 20th, 2010 at 10:18 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width