         assert(Thread.isMainThread)
         
         let wasPlaying = isPlaying()
-        let atEnd = reachedEnd
+        let atEnd = segmentCompleted
         
         //player.stop() is particular about being called from main
         player.stop()

    #endif
    
    private func interruptSessionBegin() {
        interrupted = true
        
        pause()
    }
    
    private func interruptSessionEnd(resume: Bool) {
        if interrupted && resume {
            if !engine.isRunning {
                startEngine()
            }
            
            self.resume()
        }
    }
    
    public var debugDescription: String {

    @AtomicAccessor private var pausePosition: AVAudioFramePosition

    //Tracks whether scheduled segment played up/through its expected ending frame
    @AtomicAccessor private var segmentCompleted: Bool

    //Tracks if we are in a seek operation, allows us to ignore early
    // completion callback of previously scheduled segment
