 
         avQueuePlayer.removeAllItems();
         playerTracks.removeAll();
+        trackIndex = 0
 
         pluginResult = CDVPluginResult(
             status: CDVCommandStatus_OK

            print("an error occurred when setting audio session category.\n \(error)")
        }

        self.commandDelegate!.send(
            pluginResult,
            callbackId: command.callbackId
        )
    }

    @objc(clearPlaylist:)

import MediaPlayer

@objc(CordovaPluginAudioPlaylist) class CordovaPluginAudioPlaylist : CDVPlugin {
    var avQueuePlayer:AVQueuePlayer = nil
    var playerCallbackId:String = nil;
    var playerTracks = [String, JSON]]()
    var trackIndex = 0

    @objc(initAudio:)
    func initAudio(_ command: CDVInvokedUrlCommand) {
