         }
     }
     
-    fileprivate func secondsToAVAudioTime(_ time: Double ) -> AVAudioTime {
-        let sampleTime = AVAudioFramePosition( time * internalAudioFile.sampleRate )
-        return AVAudioTime( hostTime: mach_absolute_time(), sampleTime: sampleTime, atRate: internalAudioFile.sampleRate )
+    fileprivate func secondsToAVAudioTime(_ time: Double) -> AVAudioTime {
+        let sampleTime = AVAudioFramePosition(time * internalAudioFile.sampleRate)
+        return AVAudioTime(hostTime: mach_absolute_time(), sampleTime: sampleTime, atRate: internalAudioFile.sampleRate)
     }
     
     fileprivate func scheduleBuffer(_ atTime: AVAudioTime? = nil) {
         if audioFileBuffer != nil {
             //internalPlayer.scheduleBuffer(audioFileBuffer!, completionHandler: internalCompletionHandler)
             internalPlayer.scheduleBuffer(audioFileBuffer!, at: atTime, options: .interrupts, completionHandler: internalCompletionHandler)
-        }
-    }
-    
-    fileprivate func setPCMBuffer() {
+            
+            if atTime != nil {
+                internalPlayer.prepare(withFrameCount: framesToPlayCount)
+            }
+        }
+    }
+    
+    fileprivate func updatePCMBuffer() {
         if internalAudioFile.samplesCount > 0 {
             internalAudioFile.framePosition = Int64(startingFrame)
             framesToPlayCount = endingFrame - startingFrame

    open var endTime: Double {
        get {
            return Double(endingFrame) / internalAudioFile.sampleRate
            
        }
        set {
            
            Swift.print("setting endTime to \(newValue)")
            
            let wasPlaying = playing
            
            if newValue == 0 {
                endingFrame = totalFrameCount
                
            } else if newValue < Double(startingFrame) / internalAudioFile.sampleRate

    open var startTime: Double {
        get {
            return Double(startingFrame) / internalAudioFile.sampleRate
        }
        set {
            //let wasPlaying = playing
            
            // since setting startTime will fill the buffer again, we only want to do this if the
            // data really needs to be updated
            if newValue == internalStartTime {
                //print("startTime is the same, so returning: \(newValue)")
                return
                
            } else if newValue > Double(endingFrame) / internalAudioFile.sampleRate && endingFrame > 0 {
                print("ERROR: AKAudioPlayer cannot set a startTime bigger than the endTime: \(Double(endingFrame) / internalAudioFile.sampleRate) seconds")
                
            } else {
                startingFrame = UInt32(newValue * internalAudioFile.sampleRate)
                
                Swift.print("AKAudioPlayer.startTime = \(newValue), startingFrame: \(startingFrame)")
                
                // now update the buffer
                updatePCMBuffer()
                //stop()
                
                // remember this value for ease of checking redundant calls later
                internalStartTime = newValue
            }
            // RF: I don't think this is a good idea. There are many cases where you don't want it to restart on you without
            //explicitly meaning to.
            //            if wasPlaying {
            //                play()
            //            }
        }
    }
    
