Hi! I created a simple function that will allow you to play multiple sounds at once using the Windows Media Player. (Using My.Computer.Audio.Play() will only allow 1 file to be played at once.) The sounds are from the application's resources folder or from your computer. To do this, you must import the WMPLib namespace. (You may need to reference Windows Media Player first.)
vb Code:
Private Sub Play_WMP(ResourceName As String) Dim SFX As New WindowsMediaPlayer() Dim ShortPath As String = My.Resources.ResourceManager.BaseName Dim LongPath As String = IO.Path.GetFullPath(My.Resources.ResourceManager.BaseName) Dim FullPath As String = LongPath.Substring(0, LongPath.Length - ShortPath.Length - 10) & "Resources\" SFX.URL = FullPath & ResourceName SFX.controls.play() End Sub Private Sub Play_WMP2(FileName As String) Dim SFX As New WindowsMediaPlayer() SFX.URL = FileName SFX.controls.play() End Sub
Simply call it like this:
Thanks, and good luck coding!Code:Play_WMP("JUMP.wav") Play_WMP2("C:\Users\Nic\Desktop\New folder\JUMP.wav")
~Nic




Reply With Quote
