This documentation is archived and is not being maintained.

Audio.Stop Method

Stops a sound playing in the background.

Namespace:  Microsoft.VisualBasic.Devices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public void Stop()

For more detailed information, see the Visual Basic topic My.Computer.Audio.Stop Method.

The My.Computer.Audio.Stop method stops a sound playing in the background that was started by the My.Computer.Audio.Play method.

Background playing lets the application execute other code while the sound plays. For more information, see How to: Play Looping Sounds in Visual Basic and How to: Play Sounds in Visual Basic.

In general, when an application plays a looping sound, it should stop the sound at some point.

The following table lists an example of a task involving the My.Computer.Audio.Stop method.

To

See

Stop a sound playing in the background

How to: Stop Playing Sounds in the Background in Visual Basic

This example uses the My.Computer.Audio.Stop method to stop the application currently playing background or looping sound and uses the My.Computer.Audio.Play method to play a looping sound in the background.

Sub PlayLoopingBackgroundSoundFile()
    My.Computer.Audio.Play("C:\Waterfall.wav", _
        AudioPlayMode.BackgroundLoop)
End Sub 
Sub StopBackgroundSound()
    My.Computer.Audio.Stop()
End Sub

This code example 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. These files can then be accessed through the My.Resources Object.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: