     }
 
     func doBuffer(playIndex: Int) {
-        if playIndex + 2 >= bufferredTracksJsonArray.count {
+        if playIndex + 2 >= bufferredTracksJsonArray!.count {
             // Always load 2 tracks ahead.
             if lastBufferedIndex < bufferredTracksJsonArray!.count - 1 {
                 DispatchQueue(label: "cordova-plugin-audio-playlist", qos: .background).async {
                     self.lastBufferedIndex++;
-                    self.doAddItem(self.bufferredTracksJsonArray[self.lastBufferedIndex])
+                    self.doAddItem(self.bufferredTracksJsonArray![self.lastBufferedIndex])
                     DispatchQueue.main.async {
                         self.doBuffer(playIndex: playIndex)
                     }

            self.jukebox.stop();
            self.jukebox.removeAllItems();
            self.jukebox = nil
            self.bufferredTracksJsonArray.removeAll()
            self.lastBufferedIndex = -1

            self.jukebox = Jukebox(delegate: self, items: [])!

        do {
            // configure jukebox
            jukebox = Jukebox(delegate: self, items: [])!
            bufferredTracksJsonArray = [JSON]()

            pluginResult = CDVPluginResult(
                status: CDVCommandStatus_OK
