Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with "PlaySound()" Function????

Problem with "PlaySound()" Function????

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    singersinger
    wrote on last edited by
    #1

    i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here

    S K 2 Replies Last reply
    0
    • S singersinger

      i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Well, you could use PlaySound from a secondary thread, running synchronously then posting a thread message when it completes.

      Steve S Developer for hire

      S 1 Reply Last reply
      0
      • S Steve S

        Well, you could use PlaySound from a secondary thread, running synchronously then posting a thread message when it completes.

        Steve S Developer for hire

        S Offline
        S Offline
        singersinger
        wrote on last edited by
        #3

        that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing

        D S 2 Replies Last reply
        0
        • S singersinger

          that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing

          D Offline
          D Offline
          Demian Panello
          wrote on last edited by
          #4

          Hi. Look for the mci functions like: mciSendString. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_mcisendstring.asp[^]

          Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

          1 Reply Last reply
          0
          • S singersinger

            i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here

            K Offline
            K Offline
            KaRl
            wrote on last edited by
            #5

            singersinger wrote:

            OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC

            PlaySound(NULL, 0, SND_PURGE) might do the trick if called from another thread.


            We're the regulators that de-regulate We're the animators that de-animate

            Fold with us! ¤ flickr

            1 Reply Last reply
            0
            • S singersinger

              that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing

              S Offline
              S Offline
              Steve S
              wrote on last edited by
              #6

              You want to be able to play it synchronously, yet be able to stop it playing. Can't do that, because PlaySound won't return until it's already finished. You want to play it asynchronously, and get notified when it's stopped playing. Can't do that, because PlaySound provides no notifications. However, if you read what I wrote, you can get the behaviours that you want. Spin another thread to call PlaySound synchronously. That thread can tell you when it's finished, and the effect on the other thread is that of playing it asynchronously. If you want to stop it playing, you can call playsound with a purge option (as someone else has suggested) from the original thread, which will give you what you want. Alternatively, you can try the MCI interface, or look at the waveOut* functions. However, using waveOut is a lot more complicated than using PlaySound with a second thread There's a phrase which comes to mind: If you won't like the answer, don't ask the question...

              Steve S Developer for hire

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups