Create a playlist (Android)

Create and add playlists to your Android app.



The PlaylistItem class enables you to add content to your player and define the unique characteristics of that content:

  • Title
  • Description
  • Poster image
  • Media ID

There are multiple ways to load and play content in your player. As best practice approaches, we recommend the following:

  • Use PlayerConfig.Builder() to create single-item or multiple-item playlists with media hosted in your JWP account
  • Use PlaylistItem.Builder() to create single-item or multiple-item playlists with self-hosted media
  • Use PlayerConfig.Builder() to associate a playlist to a player and to initiate media playback

πŸ“˜

While you can use other approaches to create, associate, and play playlists, PlaylistItem.Builder() and PlayerConfig.Builder() enable you to add functionality like customization and advertising.


The following sections explain how to create a single-item playlist, create a multiple-item playlist, and add multiple sources to a playlist item.



JWP-hosted Content

When your content is hosted with JWP, the metadata added to a media item when it is uploaded to your account is used in your mobile app. Additionally, you have the ability to query the Analytics API to access SDK video metrics.


Create a JWP-hosting single-item playlist

Use the following recipe to create a single-item playlist.



Self-hosted Content

If you are self-hosting your content, you can set metadata for manually building the following type of playlists:

  • Single-item playlists
  • Multiple-item playlists
  • Playlists with multiple-source playlist items

Use the following recipes to learn how to build each of these playlists.



Frequently Used Methods and Callbacks

The following tables list frequently used methods and callbacks. To view all available methods and callbacks, visit our SDK reference.


Methods

MethodDescription
List<PlaylistItem> getPlaylist()Returns the player's current playlist
int getPlaylistIndex()Returns the index of the currently active item in the playlist
PlaylistItem getPlaylistItem(int index)Returns the currently playing PlaylistItem

JWPlayerView Callbacks

CallbackDescription
onPlaylist(PlaylistEvent playlistEvent)Fired when a new playlist has been loaded into the player
onPlaylistItem(PlaylistItemEvent playlistItemEvent)Fired when the playlist index changes to a new playlist item
onPlaylistComplete(PlaylistCompleteEvent playlistCompleteEvent)Fired when the player is done playing all items in the playlist

However, if the repeat option is set true, this is never fired.
setPlaylistItemCallbackListener(playlistItemCallbackListener)Registers a listener to receive a blocking callback before the start of the next playlist item

There can only be one listener as additional assignments overwrite the previous listener.

Set the listener to null to clear to value.


© 2007-2024 Longtail Ad Solutions, Inc.