In v4, If you use AKPlayer
with looping and use setPosition
API, the player loops between the position set with setPosition
and the players total duration. What I needed was to start from the position set by setPosition
API and loop to the beginning when looping occurs. I am not sure if this is intentional or not but I need to be able to seek to a certain point in the Player and loop to the beginning and for now it seems that this is not a feature in AudioKit.
Is there a way or workaround to achieve this? I need to accomplish this as a requirement.
To reproduce here is an full playground example:
import AudioKitPlaygrounds
import AudioKit
let file = try AKAudioFile(readFileName: "3.aac")
//: Set up a player to the loop the file's playback
var player = AKPlayer(audioFile: file)
player.isLooping = true
player.buffering = .always
AKManager.output = player
try AKManager.start()
player.setPosition(player.duration - 2)
player.play(at: AVAudioTime.now())
// player loops between player.duration - 2, player.duration forever. I want it to loop between 0, player.duration
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
Expected behavior I expected it to loop back to the beginning.
Details:
- AudioKit Version 4.11.2