Browse DevX
Sign up for e-mail newsletters from DevX


New Features in Visual Studio 2005 Windows Forms : Page 5

Updated IDE features, new Menu, Toolstrip and multimedia controls, support for background threading, and a new deployment technology called ClickOnce aimed squarely at reducing the number of Web-based intranet applications are among the new capabilities in Visual Studio 2005.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

SoundPlayer Class
The SoundPlayer class, located in the System.Media namespace, provides a simple way to play .wav audio content files. Audio .wav files can be loaded from a file path, a URL, a Stream that contains a .wav file, or an embedded resource that contains a .wav file.

The SoundLocation and Stream properties are responsible for the location of the .wav file to be played. The SoundLocation property specifies the file name or URL to load. The Stream property specifies the name of a Stream-based object containing the .wav audio content to load. See Table 5 for properties relating to the SoundPlayer class.

Table 5: Properties supported by the SoundPlayer class.




Returns a Boolean value indicating if the file has been successfully loaded.


Returns or sets the number of milliseconds in which the .wav file must load.


Returns or sets the path or URL of the file to load.


Returns or sets the Stream object to load.

The Load method loads the specified .wav audio content into the control and pauses program execution until the content has loaded completely. Unless the file you are loading is very large, Load should work just fine for you. The LoadAsync method loads the specified .wav audio content on a separate thread and fires the LoadCompleted event when the content has been loaded (see Table 6).

Table 6: Methods supported by the SoundPlayer class.




Synchronously loads a .wav file into the class.


Asynchronously loads a .wav file from a stream or a Web resource on a new thread.


Plays the loaded .wav file on a new thread.


Plays the loaded .wav file on the user interface (UI) thread.


Plays and loops the loaded .wav file using a new thread.


Stops playback of the loaded audio content.

The three methods available to play the loaded audio content are Play, PlayAsync, and PlayLooping. You can load and play audio content .wav files synchronously or asynchronously. Calling the Play method asynchronously plays the audio content on a separate thread so your code can continue executing. PlaySync, on the other hand, will play the audio content synchronously and pause program execution until the playback has completed. PlayLooping works the same as Play except it will continue to loop the audio. Call the Stop method to stop the audio playback.

Dim MySoundPlayer As New System.Media.SoundPlayer MySoundPlayer.SoundLocation = _ "C:\Windows\Media\Chord.wav" MySoundPlayer.Load() MySoundPlayer.Play()

Thanks for your registration, follow us on our social networks to keep up-to-date