Audio Class
Provides methods for playing sounds.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
| Name | Description | |
|---|---|---|
![]() | Audio() | Initializes a new instance of the Audio class. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | Play(array<Byte>^, AudioPlayMode) | Plays a .wav sound file. |
![]() | Play(Stream^, AudioPlayMode) | Plays a .wav sound file. |
![]() | Play(String^) | Plays a .wav sound file. |
![]() | Play(String^, AudioPlayMode) | Plays a .wav sound file. |
![]() | PlaySystemSound(SystemSound^) | Plays a system sound. |
![]() | Stop() | Stops a sound playing in the background. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
You can use the My.Computer.Audio.Play and My.Computer.Audio.PlaySystemSound methods to play .wav sound files and system sounds.
For more information, see Playing Sounds (Visual Basic).
Project type | Available |
Windows Application | Yes |
Class Library | Yes |
Console Application | Yes |
Windows Control Library | Yes |
Web Control Library | No |
Windows Service | Yes |
Web Site | No |
The My.Computer.Audio.Play method plays the specified sound in the background when AudioPlayMode.Background is specified.
Sub PlayBackgroundSoundFile() My.Computer.Audio.Play("C:\Waterfall.wav", AudioPlayMode.WaitToComplete) End Sub
This code can run only within a Windows Forms application.
The file name should reference a .wav sound file on your system.
To simplify the management of your sound files, consider storing the files as application resources. The files can then be accessed through the My.Resources object.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

