Using the Cue object generates exception with multiple .Play calls
I had entered this as an issue, but it has now been closed and marked "As Designed". I'm pretty confused by this.
https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=198351&SiteID=226
[Note: You need to be signed into Connect first, before clicking on links to Connect will work.]
So basically, we are supposed to always use the dictionary object to look up a sound that needs played over and over again, instead of creating a Cue object to reference and replay that sound? That just doesn't sound right to me.
Has anyone else noticed this issue? Is there just something that I'm missing? I'd really like to understand why this is "As Designed" I guess.
I have some simple sample code in the issue if anyone wants to take a look and recreate what I'm talking about and maybe give me an explanation of either what I'm doing wrong or why an exception would be considered "As Designed".
I'm *no* xact expert.
BUT at an educated guess, I'd guess that its something to do with how the xact project is set up. Ive opened up my project here and the cue has a property - MaximumInstances, which is set to 1. Ive *not* tested it, but what happens if you set it to (say) 10? Do you still get the error?
Neil
Well, I don't believe LimitInstances is the same thing as what I'm trying to accomplish, but I did give it a try and it didn't change the exception.
Also, even if that had been what was causing the exception. Should you still get an exception in code because you played a sound more times than allowed by the cue? I still don't think that's an "As Designed" issue.
So setting MaximumInstances (which sets LimitInstances to True) does not fix the issue. And as Johan pointed out, LimitInstances is set to False by default for a Cue so you'd expected to be able to play it over and over again.
Why do you get an exception using a cue object to replay a sound and why is that by design? And why isn't anyone else encountering and complaining about this?
I realize the workaround is just to always play repeated sounds by retrieving them over and over again from the sound bank, but I don't like that and don't really feel that's a good design practice. So I'd really like to understand why I can't use a cue object to replay a sound.
This is the behavior of the underlying XACT APIs. With the beta, the way to play a sound multiple times is to call GetCue for each instance and then Play. For RTM, we've added a fire and forget mechanism on SoundBank, so you can now do SoundBank.Play("foo") as many times as you like and it will work. This will also clean up the Cue for you when it's done playing.
So just to make sure I understand which way the design is going.
The ONLY time you use a cue object is when you have a sound that needs to be paused and resumed.
Otherwise you ALWAYS used the GetCue method of the soundbank to play a sound.
Am I understanding it correctly? I guess it just doesn't seem very OO to me. But as long as I understand where the direction is going, I can work around it.