 
         let frameCount = (audioFile.samplesCount - startFrame) - (audioFile.samplesCount - endFrame)
 
-        if #available(OSX 10.13, *) {
+        if #available(iOS 11, macOS 10.13, tvOS 11, *) {
             playerNode.scheduleSegment(audioFile,
                                        startingFrame: startFrame,
                                        frameCount: AVAudioFrameCount(frameCount),

    // MARK: - Completion Handlers

    // this will be the method in the scheduling completionHandler >= 10.13
    @available(OSX 10.13, *)
    @objc private func handleCallbackComplete(completionType: AVAudioPlayerNodeCompletionCallbackType) {
        DispatchQueue.main.async {
            self.completionHandler?()

        let bufferOptions: AVAudioPlayerNodeBufferOptions = isLooping ? [.loops, .interrupts] : [.interrupts]

        //Swift.print("Scheduling buffer...\(startTime) to \(endTime)")
        if #available(iOS 11, macOS 10.13, tvOS 11, *) {
            playerNode.scheduleBuffer(buffer,
                                      at: audioTime,
                                      options: bufferOptions,
