Click to See Complete Forum and Search --> : Stoping the current playing audio track


Simonkale
July 15th, 2001, 08:06 AM
As written in Win32 Multimedia Programmer Reference, MCI Command String "stop" (for CD audio devices), stops playback and resets the current track position to zero. But it's not working.

On stop command button, I have put the following code

private Function Commmand1_OnClick()
'stop playback
mciSendString "stop cd", 0, 0, 0
End Function



But the above code just pause the playback and if I click play button, the track begins playback from where it was stopped. I mean there is on difference between pausing and stopping playback. If this is the case then what is written in MM reference is wrong. The MCI Command "stop" doesn't resets the current track position to zero. There has to be something wrong the code. Any help will be appreciated.

Thanks,
Simon

John G Duffy
July 15th, 2001, 09:55 AM
A MCI sample program I downloaded off Planet-Source-Code.com uses these "Stop" commands in its Unload event to close down things. This program appears to work so maybe one of these commands will solve your problem

i = mciSendString("stop sound", RS, 128, cb)
i = mciSendString("stop midi", RS, 128, cb)
i = mciSendString("stop movie", RS, 128, cb)
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("stop capture", RS, 128, cb)




John G

Simonkale
July 15th, 2001, 09:24 PM
i = mciSendString("stop cdaudio", RS, 128, cb)



Although VB complies without any error but the stop button doesn't work nor gives error msg. So I changed the code to following:

mciSendString "stop cd", 0, 128, 0



This code works but I don't know why it works! One more thing vb for some reason doesn't understands "cdaudio" so I had to change it to "cd" only. Weird?

Cimperiali
July 16th, 2001, 02:44 AM
And I am already out of votes!

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

John G Duffy
July 16th, 2001, 08:13 AM
I looked at the code from which I extracted that sample. Here is the code that both starts and Stops my CD Audio with no problems. My system is Windows ME. VB 6.0 Svc pack 5.
I had no problems starting and stopping the CD audio with this code
COmmand4 starts it and Command8 stops it with no problem

private Sub Command4_Click() ' PLAY CD
Command8_Click
Dim i as Long, RS as string, cb as Long
RS = Space$(128)
i = mciSendString("open cdaudio", RS, 128, cb)
i = mciSendString("set cdaudio time format milliseconds", RS, 128, cb)
i = mciSendString("play cdaudio", RS, 128, cb)
End Sub
'

private Sub Command8_Click() ' STOP CD
Dim i as Long, RS as string, cb as Long
RS = Space$(128)
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("close cdaudio", RS, 128, cb)
End Sub




John G