Audio Audio Audio Audio Class

Definition

Provides methods for playing sounds.

public ref class Audio
public class Audio
type Audio = class
Public Class Audio
Inheritance
AudioAudioAudioAudio

Examples

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.

Remarks

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.

Availability by Project Type

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

Constructors

Audio() Audio() Audio() Audio()

Initializes a new instance of the Audio class.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Play(Byte[], AudioPlayMode) Play(Byte[], AudioPlayMode) Play(Byte[], AudioPlayMode) Play(Byte[], AudioPlayMode)

Plays a .wav sound file.

Play(Stream, AudioPlayMode) Play(Stream, AudioPlayMode) Play(Stream, AudioPlayMode) Play(Stream, AudioPlayMode)

Plays a .wav sound file.

Play(String) Play(String) Play(String) Play(String)

Plays a .wav sound file.

Play(String, AudioPlayMode) Play(String, AudioPlayMode) Play(String, AudioPlayMode) Play(String, AudioPlayMode)

Plays a .wav sound file.

PlaySystemSound(SystemSound) PlaySystemSound(SystemSound) PlaySystemSound(SystemSound) PlaySystemSound(SystemSound)

Plays a system sound.

Stop() Stop() Stop() Stop()

Stops a sound playing in the background.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also