A Smart Audio Player

[Back to Sample VB Programs ]

 

You can create an audio player that enables you to play midi and wave files in your hard drives or DVDROM. It allows you to change drives and search for the 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 MMControl and make it invisible.

 
 

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 ]

Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved |Contact: admin@vbtutor.net

[Privacy Policy]