
-----------------------------------
Thuged_Out_G
Tue Mar 16, 2004 2:12 am

PLaying a CD
-----------------------------------
playing a cd in Visual basic is actually quite easy  :D 

first off, you'll need to start by going to the project menu, and selecting the components option. find and select Microsoft MultiMedia Control 6.0

and then you will have it on the toolbar to your left.
you then add that component to the form, and for this tutorial, we will set its visible property to "false", which will enable us to use our own buttons. 

now for the form_load() procedure.

it should look something like this


Private Sub Form_Load()
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "CDAudio"
MMControl1.Command = "Open"
End Sub


when the notify property is set to true, it generates a Done event after the next command is concluded. 
The wait property decides if the MultiMedia control will wait for the next command to finish before giving control back to the program(True=will wait, false=will not wait)
the Shareable property determines the restriction status of media devices by other procedures or programs. 
The DeviceType property is used to specify the type of MCI device(CDAudio for example)
the command="open" property opens the Cd(not actually open)

other commands that can be used with the command property are, play, open, close, pause, seek, stop, back, step, prev, next, record, eject, sound,save, track. 

now, a most basic player(included here) will have a play button, stop, pause, next, and prev. so you will either need to make a button, or include a picture for each button(method described here)

so for your play button, it would simply be this


Private Sub PlayPic_Click()
MMControl1.Command = "Play"
End Sub


the rest is pretty much self-explanatory ...for your stop button


Private Sub StopPic_Click()
MMControl1.Command = "Stop"
End Sub



now for the form unload procedure


Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop" 'stops any music playing
MMControl1.Command = "Close" 'closes the cd
End Sub


there is also the track command, which you can use to figure out the current track number playing...like this


Text1.Text=MMControl1.Command="Track"


that will put the track number in the text box Text1(must first be created)

now, the full code for a simple media player(INCLUDE YOUR OWN IMAGES)


Private Sub Form_Load()
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "CDAudio"
MMControl1.Command = "Open"
End Sub


Private Sub Image1_Click()
MMControl1.Command = "Next"
End Sub


Private Sub Image2_Click()
MMControl1.Command = "Pause"
End Sub

Private Sub Image3_Click()
MMControl1.Command = "Play"
End Sub

Private Sub Image4_Click()
MMControl1.Command = "Prev"
End Sub

Private Sub Image5_Click()
MMControl1.Command = "Stop"
End Sub

Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Close"
MMControl1.Command = "Stop"
End Sub


thats everything you need for a simple Cd player
