I have a situation where I need to schedule multiple files in sequence. I do that by calling scheduleFile multiple times:
let node = AVAudioPlayerNode()
node.scheduleFile(theAudioFile1!, at: nil)
node.scheduleFile(theAudioFile2!, at: nil)
node.scheduleFile(theAudioFile3!, at: nil)
node.scheduleFile(theAudioFile4!, at: nil)
This works fine for playback, all four files play in sequence. But, I need to add a "skip" functionality, where the press of a button skips playback forward by 15 seconds. I know how to do it using scheduleSegment (if I used scheduleSegment to initially setup the node, instead of scheduleFile), which is:
node.scheduleSegment(theAudioFile!, startingFrame: theFramePostion, frameCount: AVAudioFrameCount(theAudioFile!.length), at: nil)
and "theFramePosition" is calculated by adding 15 seconds to the node.lastRenderTime
But I can't figure out how to do it when I have multiple files playing in sequence using scheduleFile, instead of scheduleSegment.
I can combine all the four files and then use scheduleSegment using that one combined file, but I don't want to do that, as combining files takes a long time.
Can someone please suggest a solution? It will be greatly appreciated.