แก้ไข

แชร์ผ่าน


Audio Class

Definition

Provides methods for playing sounds.

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

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()

Initializes a new instance of the Audio class.

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

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

Plays a .wav sound file.

Play(Stream, AudioPlayMode)

Plays a .wav sound file.

Play(String, AudioPlayMode)

Plays a .wav sound file.

Play(String)

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)

Applies to

See also