# PlaylistAPI Protocol

    public protocol PlaylistAPI

Control and manage the playlists

- `playlistMode`

  Returns the mode used by this playlist instance.

  #### Declaration

  Swift

      var playlistMode: PlaylistMode { get }

- `onItemChange`

  Triggered when current item played in the playlist has changed.

  #### Declaration

  Swift

      var onItemChange: (() -> Void)? { get set }

- `onPlaylistEnded`

  Triggered when all items on the playlist was played.

  #### Declaration

  Swift

      var onPlaylistEnded: (() -> Void)? { get set }

- `load(items:)`

  Load new playlist.

  #### Declaration

  Swift

      func load(items: [PlayerConfiguration])

  #### Parameters

  `items` | Playlist items.

- `addItem(_:at:)`

  Add item to the playlist.

  #### Declaration

  Swift

      func addItem(_ item: PlayerConfiguration, at index: Int?)

- `replaceItem(_:at:)`

  Replace an item in the playlist at the index.

  #### Declaration

  Swift

      func replaceItem(_ item: PlayerConfiguration, at index: Int)

- `removeItem(at:)`

  Remove item from the playlist.

  #### Declaration

  Swift

      func removeItem(at index: Int)

- `swap(at:to:)`

  Swap two items in the playlist.

  #### Declaration

  Swift

      func swap(at index: Int, to: Int)

- `nextItem()`

  Start playing next item from the playlist.

  #### Declaration

  Swift

      func nextItem()

- `previousItem()`

  Start playing previous item from the playlist.

  #### Declaration

  Swift

      func previousItem()

- `playItem(at:)`

  Play item at index on the playlist.

  #### Declaration

  Swift

      func playItem(at index: Int)

- `getSize()`

  Returns number of items in the playlist.

  #### Declaration

  Swift

      func getSize() -> Int

- `getCurrentItemIndex()`

  Return the current item index in the playlist.

  #### Declaration

  Swift

      func getCurrentItemIndex() -> Int