Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Naudio.NET playsound method
- 'By TheVideoVolcano and JulioNIB
- Private Sub PlaySound(ByVal soundfilelocation As String)
- Dim reader As NAudio.Wave.WaveFileReader = New NAudio.Wave.WaveFileReader(soundfilelocation)
- Dim wavechannel As NAudio.Wave.WaveChannel32 = New NAudio.Wave.WaveChannel32(reader)
- Dim player As NAudio.Wave.DirectSoundOut = New NAudio.Wave.DirectSoundOut
- Try
- player.Init(wavechannel)
- If Exists(soundfilelocation) Then
- player.Play()
- end if
- player.Dispose()
- Catch
- End Try
- End Sub
- '---------------------------------------------------------------------------------------------------
- 'use like this
- PlaySound("C:\file.wav", true)
- '---------------------------------------------------------------------------------------------------
- '--Extras--
- wavechannel.skip(1) 'skip 1 second into the .wav file
- player.stop 'stops sound
- player.volume = 1 '1 is default 0.5 is half
- 'See more on the documentation at Naudio's site.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement