CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1

    Stoping the current playing audio track

    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


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Stoping the current playing audio track

    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

  3. #3

    Re: Stoping the current playing audio track


    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?


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Whow!

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



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

  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Stoping the current playing audio track

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured