article

Playing Music with Microsoft Direct X 9

Email
Submitted on: 1/1/2015 3:13:00 PM
By: EJ T (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: VB.NET
Views: 717
 
     This tutorial will give you the knowledge to use Microsoft Direct X 9 to play music in your applications. We will do this by using the Direct X 9 Audio class.

 
				
<--[if gte mso 10]>




Microsoft Direct X 9 Audio

 

Overview:

This tutorial will give you the knowledge to use Microsoft Direct X 9 to play music in your applications. We will do this by using the Direct X 9 Audio class.

 

Prerequisites:

You will need Microsoft Direct X 9 SDK and Microsoft Direct X 9 Componentized VB

You can download them from:

http://www.msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp

 

Start:

1)      Open Visual Basic.NET and create a new windows application

2)      The right click on references and click Add

3)      Under the .Net panel double click on Microsoft.DirectX and Microsoft.DirectX.AudioVidioPlayback

4)      Now click OK

5)      Open Form1 in code view and at the top, before the class declaration, type:

Imports Microsoft.DirectX

Imports Microsoft.DirectX.AudioVideoPlayback

6)      Then go back to design view and add a button onto the form

7)      Double click the button and add the fowling code

Dim OpenFile As New System.Windows.Forms.OpenFileDialog() 'Create a dialog

OpenFile.ShowDialog() 'Shows the Dialog so the user can select the file

Dim AudioFile As Audio 'Create a new audio object that can play audio files

AudioFile = New Audio(OpenFile.FileName) 'Lodes the file into the AudioFile Object

 

 

8)      Click play and enjoy

NOTE: When the file dialog comes up, only select an audio file

(Another) NOTE: I know that this code could use some error handling, and a better interface, but I just wanted to proved a way to play music in Microsoft DirectX 9

 

Please Vote and Comment


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.