Audio.Stop 方法


停止在后台播放声音。Stops a sound playing in the background.

 void Stop();
public void Stop ();
member this.Stop : unit -> unit
Public Sub Stop ()


此示例使用My.Computer.Audio.Stop方法来停止当前正在播放的背景或循环声音,并My.Computer.Audio.Play使用方法在后台播放循环声音。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()
End Sub
Sub StopBackgroundSound()
End Sub

此代码示例只能在 Windows 窗体应用程序中运行。This code example can run only within a Windows Forms application.

文件名应引用您的系统上的 .wav 声音文件。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. 然后, My.Resources可以通过对象访问这些文件。These files can then be accessed through the My.Resources object.


方法停止在后台播放的声音,该声音My.Computer.Audio.Play由方法启动。 My.Computer.Audio.StopThe My.Computer.Audio.Stop method stops a sound playing in the background that was started by the My.Computer.Audio.Play method.

一般情况下,应用程序播放循环声音时,声音将在某个时间点停止。In general, when an application plays a looping sound, it should stop the sound at some point.

有关详细信息,请参阅播放声音For more information, see Playing Sounds.

按项目类型的可用性Availability by Project Type

项目类型Project type 可用Available
Windows 应用程序Windows Application Yes
类库Class Library Yes
控制台应用程序Console Application Yes
Windows 控件库Windows Control Library Yes
Web 控件库Web Control Library NoNo
Windows 服务Windows Service Yes
网站Web Site NoNo