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#
  4. My sound stops playing when the form loses focus

My sound stops playing when the form loses focus

Scheduled Pinned Locked Moved C#
questionhelp
3 Posts 3 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.
  • D Offline
    D Offline
    DemonicDominic
    wrote on last edited by
    #1

    Hi yall, I've written an app which plays wav files continually using DirectSound. Everything works fine until the app form loses focus, which causes the sound to stop playing. Thing is, i'd like the app to keep playing the sounds in the background while doing other stuff. How can I do this??? Thanx for any help, Dominic

    L O 2 Replies Last reply
    0
    • D DemonicDominic

      Hi yall, I've written an app which plays wav files continually using DirectSound. Everything works fine until the app form loses focus, which causes the sound to stop playing. Thing is, i'd like the app to keep playing the sounds in the background while doing other stuff. How can I do this??? Thanx for any help, Dominic

      L Offline
      L Offline
      leckey 0
      wrote on last edited by
      #2

      Found this in the CP archives: DirectSound plays only when the window which is passed to SetCooperativeLevel, is foreground. If it passes to background, the playback stops until again the wnd becomes foreground. Unfortunately, this is the way how DirectSoundBuffer works. PlaySound API is process-wise (application-wise). Two (or more) processes can play sounds simultaneously but a single application can play one sound in a given time period. How intensively your app is going to play/stop sounds? (If it's not so intensive, maybe creating a child process per sound would do). ...

      Blog link to be reinstated at a later date.

      1 Reply Last reply
      0
      • D DemonicDominic

        Hi yall, I've written an app which plays wav files continually using DirectSound. Everything works fine until the app form loses focus, which causes the sound to stop playing. Thing is, i'd like the app to keep playing the sounds in the background while doing other stuff. How can I do this??? Thanx for any help, Dominic

        O Offline
        O Offline
        oobimoo
        wrote on last edited by
        #3

        Set BufferDescription's GlobalFocus property to true

        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