Location My.Computer.Audio.Play Syntax My.Computer.Audio.Play(location[, playMode]) or: My.Computer.Audio.Play(data, playMode) or: My.Computer.Audio.Play(stream, playMode)
location (required; String) The path to the sound file.
data (required in syntax 2; Byte array) The binary content of a sound file stored in a Byte array.
stream (required in syntax 3; Stream) The binary content of a sound file accessed through a System.IO.Stream object.
playMode (optional in syntax 1; AudioPlayMode enumeration) The method by which the sound should be played. One of the following Microsoft.VisualBasic.AudioPlayMode enumeration values. Value | Description |
---|
Background | Starts playing the sound in the background one time. The program continues with the next source-code statement. | BackgroundLoop | Starts playing the sound in the background in a loop until stopped with the My.Computer.Audio.Stop method. The program continues with the next source-code statement. | WaitToComplete | Plays the sound but does not continue with the next source-code statement until the playing of the sound ends. |
If omitted, the default value is Background. Description The Play method plays a sound (WAV) through the system speakers. The WAV sound content can be accessed as a file, a Byte array, or a Stream. Usage at a Glance This method is only valid in non-server applications. Using an invalid or empty data source will cause an exception, as will using an invalid play mode. Trying to play a file-based sound without sufficient privileges will cause an exception. Example The following example plays a disk-based WAV file and waits for it to complete. My.Computer.Audio.Play("C:\YouWin.wav", _ AudioPlayMode.WaitToComplete) Related Framework Entries Microsoft.VisualBasic.Devices.Audio.Play Method System.Media.SoundPlayer Class System.Media.SoundPlayer.Play Method System.Media.SoundPlayer.PlayLooping Method System.Media.SoundPlayer.PlaySyncMethod See Also Audio Object, PlaySystemSound Method, Stop Method |