AudioKit / Cookbook

Canonical Examples for Using the AudioKit Framework
MIT License
606 stars 97 forks source link

Error in CompletionHandlerConductor file. #134

Closed NewajShovo closed 12 months ago

NewajShovo commented 12 months ago

macOS Version(s) Used to Build

macOS 13 Ventura

Xcode Version(s)

Xcode 14

Description

  1. Open Audiokit
  2. Select Audio player
  3. Select Completion handler

Expected: All audio will be played one by one. Found: First and second files can only be heard, other audio files are not being played.

Crash Logs, Screenshots or Other Attachments (if applicable)

No response

NewajShovo commented 12 months ago
func playNextFile() {
    currentTime = 0.0
    if currentFileIndex < 4 {
        print("Starting if block");
        currentFileIndex += 1
        player = AudioPlayer();
        try? player.load(url: fileURL[currentFileIndex])
        engine.output = player
        player.play();
        player.completionHandler = playNextFile
    } else {
        print("Starting else block");
        currentFileIndex = 0
        player = AudioPlayer();
        try? player.load(url: fileURL[currentFileIndex])
        engine.output = player
        player.play();
        player.completionHandler = playNextFile
    }
}

Changing playNextFile function like the above solve the problem.
aure commented 12 months ago

This doesn't seem to be an issue with the Cookbook per se and it doesn't seem to be a good solution either. You're changing the signal graph on playing a file.