Visual Basic has internal classes that easily assist you in coding audio applications. Media Player is a Windows application that can be used in Visual Basic to play audio, such as audio files in the MP3 format. Media Player contains DLL (dynamic link libraries), which are included in Microsoft's programming products. This means that you can drag and drop objects that play music without numerous lines of code.
- Skill level:
Things you need
- Visual Basic 6.0
- Media Player
- MP3 file
Open up your Windows project in the Visual Basic editor. Double-click the form to have it open in the design viewer. You need to add the Media Player object to the project since it is not loaded into the toolbar automatically.
Right-click on the toolbar and choose the "Add/Remove Items" option. This will open up a new window box with a list of tools. Click on the "COM Components" tab, then go down to the option box entitled "Windows Media Player." Place a check in this the box, then click "OK."
Drag and drop the Media Player tool from the toolbar into the Visual Basic form. Input "myMedia" into the "Name" property for the Media Player tool, then double-click on the icon to open the code view.
Assign the MP3 music file to the component. The following code will play the song "mySong.mp3" using the Media Player component: Me.myMedia.URL = "mySong.mp3."
Press the "F5" key after saving the form. "F5" runs the code in the debugger that tests the application. "F5" is used to make sure that the new code compiles and plays the song within the visual Basic application.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for