A Smart Audio Player

 

This is an audio player created using Visual Basic 6 that enables the user to browse and  play music files of different formats in your hard drives, pen drives , DVD or any other storage devices. It allows you to change drives and search for a particular sound file that you wish to play.

In this program, you have to add a Combo box, a List Box, a Text Box, a Drive List Box and three command buttons. Change the label of  one of the buttons to "PLAY", another command button to "STOP", and the last command button to "EXIT". Besides, you need to add the Microsoft Multimedia Control . To include the multimedia control as one of the tools, click on project on the menu and select components, then click on Microsoft Multimedia Control 6.0. Drag the MM Control into your form and make it invisible at startup.

 

 

The code

 
 

Sub Combo1_Change( )
if ListIndex=0 Then
File1.Pattern=("*.wav")
ElseIf ListIndex=1 Then
File1.Pattern=("*.mid")
Else
File1.Pattern=("*.*)
End If

End Sub

If Right(File1.Path,1) <>"\" Then
 filenam=File1.Path +"\"+File1.Filename

Else
filenam=File1.Path+File1.Filename

End If

Text1.Text=filenam

End Sub

Private Sub Play_Click( )
If Combo1.ListIndex=0 Then
MMControl1.DeviceType="WaveAudio"
ElseIf Combo1.ListIndex=1 Then
MMControll.DeviceType="Sequencer"
End If

MMControl1.FileName=Text1.Text
MMControl1.Command="Open"
MMControl1.Command="Play"

End Sub

 

Private Sub Stop_Click( )
If MMControl1.Mode=524 Then Exit Sub
If MMControl1.Mode<>525 Then
MMControl1.Wait=True
MMControl1.Command="Close"

End Sub

 

Private Sub Dir1_Change( )
File1.Path=Dir1.Path
If Combo1.ListIndex=0 Then
File1.Pattern=("*.wav")
ElseIf Combo1.ListIndex=1 Then
File1.Pattern=("*.mid")
Else
File1.Pattern=("*.*)
End If

Private Sub Drive1.Change( )
Dir1.Path=Drive1.Drive
End Sub

Private Sub Form_Load( )
Top=(Screen.Height-Height)\2
Left=(Screen.Width-Width)\2
Combo1.Text="*.wav"
Combo1.AddItem "*.wav"
Combo1.AddItem "*.mid"
Combo1.AddItem "All files"

End  Sub

 

 

 

[Back to Sample VB Programs ]