             print("an error occurred when setting audio session category.\n \(error)")
         }
 
-        self.commandDelegate!.send(
-            pluginResult,
-            callbackId: command.callbackId
-        )
+        // MPNowPlayingInfoCenter
+        UIApplication.shared.beginReceivingRemoteControlEvents()
+
+        NotificationCenter.default.addObserver(self, selector: #selector(self.updateSongStatus), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.avQueuePlayer.currentItem)
+
+        self.commandDelegate!.send(
+            pluginResult,
+            callbackId: command.callbackId
+        )
+    }
+
+    deinit {
+        if avQueuePlayer != nil {
+            NotificationCenter.default.removeObserver(self, name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.radioPlayer.currentItem)
+        }
     }
 
     @objc(clearPlaylist:)

        output["album"] = data["album"].stringValue
        output["cover"] = data["cover"].stringValue
        output["url"] = url
        
        switch item.status {
        case .readyToPlay:
        // Player item is ready to play.
            output["status"] = 1
        case .failed:
        // Player item failed. See error.
            output["status"] = 2
        case .unknown:
            // Player item is not yet ready.

            avQueuePlayer.play();
        }

        playerTracks[data["url"].stringValue] = data

        pluginResult = CDVPluginResult(
            status: CDVCommandStatus_OK
