Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally speaking, OpenAL won't notify you when audio has finished playing, so there's no real equivalent to the <code>AVAudioPlayerDelegate</code>. The <em>easiest</em> way is to simply delay a function/block call by the length of the audio. As an example, you could use libdispatch (aka Grand Central Dispatch) to add a block to a queue after a set amount of time:</p> <pre><code>dispatch_time_t delay; dispatch_queue_t queue; dispatch_block_t block; uint64_t audio_length_ns = 10000000000; // 10 seconds delay = dispatch_time(DISPATCH_TIME_NOW, audio_length_ns); queue = dispatch_get_main_queue(); block = ^{ // Do whatever you need to after the delay // Maybe check to see if the audio has actually // finished playing and queue up the block again // if it hasn't. }; // Queue up the block for the time after dispatch_after(delay, queue, block); </code></pre> <p>The slightly harder way is, as mentioned in the comment inside the block, to check if OpenAL is finished in the block and, if it isn't, to push the block onto the queue again (probably with a shorter delay, especially if you can approximate how much longer it'll be). In general, though, you probably won't need to be spot-on and just being in a decent range of the sound's completion is good enough.</p> <p>You can also schedule this sort of thing via other methods, like <code>performSelector:withObject:afterDelay:</code>, but that comes down more to your preference as far as API is concerned. The idea is pretty much the same.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload