Reply To: Pausing app while FliteController is speaking

Home Forums OpenEars Pausing app while FliteController is speaking Reply To: Pausing app while FliteController is speaking

Halle Winkler

Sounds like a nice app, always happy to hear about that kind of use of OpenEars. This is more of a general application design question but I don’t mind taking a stab at it.

I think that the most efficient way to deal with this kind of issue is to launch the follow-up method (in this case whatever the “ask next question” method is) _from_ fliteDidFinishSpeaking (as part of an OpenEarsEventsObserver instance that is instantiated in the class whether the follow-up method lives). Generally, a good pattern for that kind of approach is to have a “queue” of questions which are added to an NSMutableArray at whatever point you know what they are supposed to be, and every time fliteDidFinishSpeaking is called you check the queue to see if there are any questions left in it to ask. If there is a next question in the queue, you launch your question method using that question from fliteDidFinishSpeaking and also remove it from the queue. Eventually you will run out of questions and fliteDidFinishSpeaking will not result in another question being asked. If logic dictates that there are new questions that should be asked, you add them to the queue. Does that make sense?