Link to home
Start Free TrialLog in
Avatar of sintec_ch
sintec_ch

asked on

Playing a wave sound upon application start

hello. i want to add some interactivity to my program and play .wav sound files upon certain user actions. how can i play wave sounds in visualbasic.net?

best regards, chris
Avatar of AlexFM
AlexFM

ASKER CERTIFIED SOLUTION
Avatar of iboutchkine
iboutchkine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can save some of the hassle by adding the Windows Media Player to your application either by simply adding teh com component to you toolbox and then using it as any other control or by downloading teh Windows Media Player 9 SDK which has a set of handeled classes for the Media Player.

Com Way:

Right click on your toolbox and select Add/Remove
Change to the COM tab and then scroll down the list for Windows Media Player (WMP.DLL) and add it
Drag the new icon to your form
Set visible to false

add this code to your Forms Load event

        With AxWindowsMediaPlayer1
            .launchURL(strFilePath)
        End With

SDK way:

Create a reference to the WMPlib.dll extracted during the installation of the media player SDK in your application, using the add reference option on the project menu again from teh com tab
Add Imports WMPLib to teh start of your class
then create a new instance of the windows media player as below

Dim WMP As New WindowsMediaPlayer
        With WMP
            .launchURL(strFilePath)
        End With

hope it helps... good luck

By the way also if you use either the WMP9 or 10 SDK in your app and use WMA sound files you can use the Designed for Windows Media Player logo for your application... http://www.microsoft.com/windows/windowsmedia/licensing/logo.aspx