      the `currentPage` in ReaderCenter may not have updated just yet
      */
     func getCurrentChapterName() -> String? {
+        guard let chapter = FolioReader.sharedInstance.readerCenter.getCurrentChapter() else {
+            return nil
+        }
+        
+        currentHref = chapter.href
+        
         for item in book.flatTableOfContents {
             if let resource = item.resource where resource.href == currentHref {
                 return item.title

        let session:AVAudioSession = AVAudioSession.sharedInstance()
        try! session.setCategory(AVAudioSessionCategoryPlayback)
        try! session.setActive(true)
    }
    
    deinit {


            let fileURL = currentSmilFile.resource.basePath().stringByAppendingString("/"+audioFile!)
            let audioData = NSData(contentsOfFile: fileURL)
            
            do {
            
                player = try AVAudioPlayer(data: audioData!)
                
                guard let player = player else { return false }
                
                setRate(FolioReader.sharedInstance.currentAudioRate)
                player.enableRate = true
                player.prepareToPlay()
                player.delegate = self
                
                updateNowPlayingInfo()
            } catch {
                print("could not read audio file:", audioFile)
                return false
            }
        }

        // if player is initialized properly, begin playing
        guard let player = player else { return false }

        // the audio may be playing already, so only set the player time if it is NOT already within the fragment timeframe
        // this is done to mitigate milisecond skips in the audio when changing fragments
        if player.currentTime < currentBeginTime || ( currentEndTime > 0 && player.currentTime > currentEndTime) {
            player.currentTime = currentBeginTime;
            updateNowPlayingInfo()
        }

        player.play()

        // get the fragment ID so we can "mark" it in the webview
        let textParts = textFragment!.componentsSeparatedByString("#")
        let fragmentID = textParts[1];
        FolioReader.sharedInstance.readerCenter.audioMark(href: currentHref, fragmentID: fragmentID)

        return true
    }
