|
-
August 29th, 2009, 07:07 PM
#6
Re: playing sounds...
 Originally Posted by Gun Monkey
---------------------------------------------------------------------------------
Dim player As New System.Media.SoundPlayer("C:\song.wav")
player.Play()
---------------------------------------------------------------------------------
Using the code you gave me before...all went ok, except I need the file to play from the folder the program runs from. I don't know how to write the file location so that it does that...
Also, I need the sound to overlap itself. When the program plays the sound, it cuts the sound off the last part off the previous sound to play the next time around. Since the user can change the rate at which the sound plays, if the rate-of-fire is faster than the sound file can play, the cut-off thing happens. Is there a way to let the previous sound play as the next one does so they overlap?
If you need to the file to be played from the folder that the program runs form, directly put the FILENAME then, e.g.
Dim player As New System.Media.SoundPlayer("song.wav")
In this case, the sound player will play the file from the application's start up folder.
(This technique is appliable to other functions that open file as well)
If you need the sound to be overlapped, umm. It seeems that soundplayer cannot play multiple of them at the same time even if you "new" a sound player.
I think you have to use the second method that I suggest, the API approach.
I have made an example for you. Remember to copy the above API definition to your form class.
Code:
mciSendString("Open ""song.wav"" Alias MySong", "", 0, 0)
mciSendString("Play MySong", "", 0, 0)
System.Threading.Thread.Sleep(1000)
mciSendString("Open ""song.wav"" Alias MySong2", "", 0, 0)
mciSendString("Play MySong2", "", 0, 0)
Using this example, you should listen two audio broadcasting in an overlapped way (a one second delay)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|