Play embedded WAV Files

Source: Internet
Author: User

'Clarations...

'Play sound flags
Private const snd_async as integer = & H1
Private const snd_loop as integer = & H8
Private const snd_memory as integer = & h4
Private const snd_nodefault as integer = & H2
Private const snd_nostop as integer = & H10
Private const snd_sync as integer = & H0

'Play sound Declaration
Declare function sndplaysound lib "winmm. dll" alias "sndplaysounda" (byval lpszsoundname as byte (), byval uflags as integer) as integer

'Calling code...

'Name of the resource to extract
Dim rname as string = "cameraclick.wav"
'Obtain the Assembly name and replace '-' with an underscore
Dim rschema as string = Replace (reflection. Assembly. getexecutingassembly. getname. Name, "-", "_") & "." & rname
'Retreive the resource as a stream
Dim rstream as Io. Stream = reflection. Assembly. getexecutingassembly. getmanifestresourcestream (rschema)
'Read the stream into a byte Buffer
Dim buffer (rstream. Length) as byte
Rstream. Read (buffer, 0, buffer. Length-1)
'Play the sound
Sndplaysound (buffer, snd_memory or snd_async)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.