How to Play a WAV File Using DirectX With Visual Basic

With the DirectX engine, you can create media that interfaces with your computer's video and sound cards. You can use the DirectX plugin in your Visual Basic applications to play WAV files in your software. You must first create a DirectX variable and then specify the WAV file you want to play. The "Play" function plays the music, but you can play the music at any point during your interaction with the application.

Instructions

    • 1

      Click the Windows "Start" button and select "All Programs." Click "Microsoft Visual Basic," then click "Visual Basic 6" to open the software. Open the VB project after the workspace loads.

    • 2

      Right-click the form you want to use to play the WAV file and click "View Code." The VB code opens in the editor.

    • 3

      Add the DirectX library to your code. To accomplish this, add the following code to the top of the file:

      Imports Microsoft.DirectX.AudioVideoPlayback

    • 4

      Create a DirectX variable. The following code creates a variable for the DirectX plugin:

      Dim music As Audio

    • 5

      Play the file. The following code demonstrates how to play a WAV file in the Visual Basic app:

      music = new Audio("myfile.wav")

      music.Play()

Related Searches:

References

Comments

Related Ads

Featured