XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

[3.0 CTP] Checking if sound is playing?

Last post 6/6/2008 3:23 PM by Huntsman. 7 replies.
  • 5/25/2008 4:58 PM

    [3.0 CTP] Checking if sound is playing?

    Is there any way to check if the sound is already playing, i.e. only play one instance of the sound at a time (using SoundEffect instead of XAct)?

    I assumed it would be something like this:

    if (sound.Play().State != SoundState.Playing)
     sound.Play

    but the sound starts to play when calling " sound.Play().State " so cant really do this.
  • 5/27/2008 9:37 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    You need to store away the cue to know if its playing.

    I am myself having trouble though playing the same cue twice, the flag IsPrepared is false after I play it once and I don't know how to "prepare" the cue again.

  • 5/28/2008 5:30 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    How do you use the cue to play a sound?

    Currently all I do is:

    private SoundEffect sound;

    sound.Play();

  • 5/28/2008 8:37 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    You sae the result of SoundEffect.Play() in a class instance variable and perform the check like
    if (sfxInstance != null && sfxInstance.State != SoundState.Playing)  
    {  
        sfxInstance = sound.Play();  

    As for using Cues: read the XACT topic in the How to section of the documentation.

    We are boki. The rest is known.

    The not so known part of the rest: It is Björn or Bjoern, but never Bjorn.

    Twitter ~ Bnoerj ~ SharpSteer ~ SgtConker.com
  • 5/28/2008 8:38 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    reallyjoel:
    I am myself having trouble though playing the same cue twice, the flag IsPrepared is false after I play it once and I don't know how to "prepare" the cue again.

    Cues are a play once instance only and hence you need to get a new one from the SoundBank.

    We are boki. The rest is known.

    The not so known part of the rest: It is Björn or Bjoern, but never Bjorn.

    Twitter ~ Bnoerj ~ SharpSteer ~ SgtConker.com
  • 5/28/2008 9:20 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    dont know what you mean by this, how would you do this "You save the result of SoundEffect.Play() in a class instance variable"
  • 5/28/2008 11:36 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    //Declare this as a class member

    private SoundEffectInstance _sei;

    then do:

    _sei = SoundEffect.Play();

    edit: Got 2.0 on the brain. :(

    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 6/6/2008 3:23 PM In reply to

    Re: [3.0 CTP] Checking if sound is playing?

    Awesome, this thread was extremely helpful.  Thanks
Page 1 of 1 (8 items) Previous Next