Seat Media Queue#
The Seat Media Queue API allows to you to manage the Media Queue by providing commonly used features, such as play, pause, stop, shuffle and repeat. The Media Queue API can be used by itself or with Seat Pairing. As an interactive developer, there is no need to implement the shuffle mode, or repeat mode in the interactive.
Media Queue Object Initialization using Pairing#
- Initialize the seat pairing service to allow the Personal Electronic Device (PED) to interact with the seatback monitor and declare the media queue as a property of the class.
Property Declaration
mediaQueue is declared as a property of the class. This object represents the service that manages the media queue between the PED and the IFE system.
- Initialize the seat pairing service. This enables the communication between the PED and seatback monitor.
Pairing Initialization
Pairing.initService(context, new IInFlightCallback() {
@Override
public void onInitServiceComplete (Object o, String s){
// If the initialization succeeds, cast the returned object into SeatPairingV1
mPairing = (Pairing) o;
if (mPairing != null) {
// Perform operation like observing pairing status, which mentioned in the below code snippet
mediaQueue = mPairing.getMediaQueue();
}
}
@Override
public void onInitServiceFailed (String s, InFlight.Error error){
// Handle initialization failure
}
},new InFlight());
Follow these steps:
-
Initialize PairingService by calling
initServiceon thePairing, then passing a callback to handle successful initialization. -
Store the SeatPairingService Instance. The
Pairingobject is stored in a class-level property calledmPairing. This allows the app to interact with the pairing service. -
Retrieve
mediaQueue.mediaQueueis accessed through thePairing, enabling media queue management between the PED and the seatback monitor. -
With the media queue service initialized, the app can now perform actions , such as adding, removing or modifying items, in the queue
Creating Media Queue Items#
In a media queue, there are multiple ways to create items. You can use the following three methods to generate media queue request items, depending on the available parameters and requirements. Each method allows you to customize and structure the media queue.
- MediaQueueRequestItem(String mediaUri)
This constructor creates a new MediaQueueRequestItem object with the provided media URI. It’s useful for creating a media queue request item with the specified URI, which can oad or launch media in the queue.
- MediaQueueRequestItem(String globalUri, String mediaUri, String soundTrack, String subtitle, JSONObject extras)
This constructor creates a new MediaQueueRequestItem object with detailed information about a media item. This constructor is useful for creating a media queue request item with comprehensive details, which can then be used to load or launch media in the queue with specific configurations and additional information.
Parameters:
String globalUri: Global URI of the media item.String mediaUri: URI of the specific media item to be added to the media queue.String soundTrack: Soundtrack associated with the media item.String subtitle: Subtitle associated with the media item.JSONObject extras:JSONObjectcontaining any additional information such assourceis playlist or album
- MediaQueueRequestItem(String globalUri, String mediaUri, String soundtrack, String subtitle, Bookmark bookmark, JSONObject extras)
This constructor creates a new MediaQueueRequestItem object with detailed information about a media item.
This constructor is useful for creating a media queue request item with comprehensive details, including a bookmark for resuming playback from a specific point, and any additional metadata needed for the media item.
Note: When including a bookmark in the payload for the load or launch queue API, priority is assigned to the items within the bookmark. For example, if the bookmarked media contains a soundtrack or subtitle labeled as "eng", takes precedence over any soundtrack or subtitle options sent separately.
Parameters:
-
String globalUri: Global URI of the media item. -
String mediaUri: URI of the specific media item to be added to the media queue. -
String soundtrack: Soundtrack associated with the media item. -
String subtitle: Subtitle associated with the media item. -
Bookmark bookmark: Bookmark object containing the media URI, elapsed time, subtitle and soundtrack of the current item. -
JSONObject extras:JSONObjectcontaining any additional information such assourceas playlist or album
Load Media Queue API#
Follow these steps:
1. Add the item to the queue. Additionally, this method clears the existing queue.
loadMediaQueue(List
List<MediaQueueRequestItem> mediaQueueRequestItemList = new ArrayList<>();
MediaQueueRequestItem item1 = new MediaQueueRequestItem("media:uri");
mediaQueueRequestItemList.add(item1);
mediaQueue.loadMediaQueue(mediaQueueRequestItemList, 0, MediaQueue.RepeatModeType.NONE, true, new MediaQueue.MediaQueueItemsAddedListener() {
@Override
public void onItemsAddComplete(List<MediaQueueItem> list, List<MediaQueueItem> list1) {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters:
-
items : adds the list of items to the end of the media queue.
-
startIndex: sets the selected item index in the queue.
-
repeatMode : accepts the value of MediaQueue.RepeatModeType enum
-
autoPlay : starts the playback of an item at launch media. A boolean value. If true, media automatically plays at load. If false, media does not play automatically and the passenger must select the Play button
-
listener : invoked when items are added to the media queue.
MediaQueue.MediaQueueItemsAddedListener
Methods to Modify Media Queue#
You can manage media queue items, such as adding, removing, or clearing items from the queue. Each method provides a flexible way to interact with the media playback on a seatback monitor. Items in the media queue include various details such as media URIs, soundtracks, subtitles, and other attributes. Completion blocks are used to handle the results of these operations, ensuring that you can track success or handle any errors.
1. Add the item at the end of the media queue
addItems (List
List<MediaQueueRequestItem> list = new LinkedList<>();
MediaQueueRequestItem mediaQueueRequestItem = new MediaQueueRequestItem("media:url");
list.add(mediaQueueRequestItem);
mediaQueue.addItems(list, new MediaQueue.MediaQueueItemsAddedListener() {
@Override
public void onItemsAddComplete(List<MediaQueueItem> list, List<MediaQueueItem> list1) {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters:
-
mediaItems - List of items to be added to the end of the media queue.
-
listener - MediaQueue.MediaQueueItemsAddedListener It is invoked when items are added to the media queue.
2. Add the media queue item at the specific location in the queue
insertItems (List
List<MediaQueueRequestItem> list = new LinkedList<>();
MediaQueueRequestItem mediaQueueRequestItem = new MediaQueueRequestItem("media:url");
list.add(mediaQueueRequestItem);
mediaQueue.insertItems(list, 5, new MediaQueue.MediaQueueItemsAddedListener() {
@Override
public void onItemsAddComplete(List<MediaQueueItem> list, List<MediaQueueItem> list1) {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters :
-
mediaItems - List of items to be added to the media queue.
-
position - Index where the items are to be inserted
-
listener - MediaQueue.MediaQueueItemsAddedListener It is invoked when items are added to the media queue.
3. removeItems (List
The method used to remove the item from the media queue
List<String> list = new LinkedList<>();
String queueIdToBeRemove = "media:url";
list.add(queueIdToBeRemove);
mediaQueue.removeItems(list, new MediaQueue.MediaQueueItemsRemovedListener() {
@Override
public void onItemsRemoveComplete(List<MediaQueueItem> list, List<MediaQueueItem> list1) {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters:
-
queueIds - Unique identifier for the media items in the queue.
-
listener - MediaQueueItemsRemovedListener listener It is invoked when items are removed from the media queue.
Returns:
True if successfully sent
False if it cannot be sent.
4. clearQueue(MediaQueue.MediaQueueItemsClearedListener listener)
The method is used to remove all the items from the queue and provide the response using its listener.
mediaQueue.clearQueue(new MediaQueue.MediaQueueItemsClearedListener() {
@Override
public void onItemsClearComplete() {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters :
- listener - MediaQueue.MediaQueueItemsClearedListener It is invoked when the items are removed from the media queue.
Media Control Operations#
1. play()
The method used to start or continue playback of the current item in the media queue.
2. play(String contentType)
The method used to play the media item with the specified content type.
Parameter :
contentType - A content type of the media needs to provide
3. pause()
The method used to pause the currently playing media.'
Return:
It returns true if the command is sent successfully, otherwise false
4. stop()
The method used to stop playing media items of the media queue
Return :
it returns true if the command is sent successfully, otherwise false
Media Playback Settings#
1. jumpTo(String queueId)
The method used to jump to media items with the specified media queueId in the queue.
Parameters:
queueId - Unique identifier of the item in the queue.
Returns:
Return true, if the message is successfully sent, false otherwise
2. jumpToNext()
The method used to jump to the next item in the media queue
Returns:
Return true, if the message is successfully sent, false otherwise
3. jumpToPrev
The method used to jump to the previous item in the media queue.
Returns:
Return true, if the message is successfully sent, otherwise false
4. setDefaultSubtitleCode(String code)
The method used to set the language code for the subtitle in the media queue
Parameters:
code - Default ISO 639-2 language code for the subtitles
Returns:
Return true, if the message is successfully sent, false otherwise
5. setDefaultSubtitle(String code, String type)
The method used to set language code and type for subtitles in the media queue
Parameters: code - Default ISO 639-2 language codes for the subtitles
type - the type of the subtitle, e.g. dialog, description, embedded, etc
6. setDefaultSoundtrackCode(String code)
The method used to set the language code for the soundtrack in the media queue
Parameters:
code - Default ISO 639-2 language codes for the soundtrack
Returns:
Return true, if the message is successfully sent, false otherwise
7. setDefaultSoundtrack(String code, String type)
The method used to set the default language code and type for the soundtrack in the media queue
Parameters:
code - Default ISO 639-2 language codes for the soundtrack.
type - set soundtrack type
Returns:
Returns true if the message is successfully sent, otherwise false
8. setShuffleMode(boolean shuffle)
The method used to shuffle the media queue items. The seat service manages the shuffling algorithm. The SDK layer is not responsible for shuffling the media queue
Parameters:
shuffle - Random order for playing the media items.
Returns:
Return true, if the message is successfully sent, otherwise false
9. setRepeatMode(MediaQueue.RepeatModeType mode)
The method used to set the media queue to play the items multiple times. The values are All to repeat all the items, None to not repeat the media queue, One to repeat only the current item, or Unknown.
Parameter:
repeatMode - It accepts the value of MediaQueue.RepeatModeType enum
Media Queue Details#
The following properties and methods provide information about and control over the media queue. These can be used to retrieve various details such as language settings, playback modes, item existence, and more.
1. getItems(PagingOption pagingOption, MediaQueue.GetMediaQueueItemsListener listener)
The method is used to get a list of media queue items. If the paging option is not specified, all items are returned
PagingOption pagingOption = new PagingOption(0,50);
mediaQueue.getItems(pagingOption, new MediaQueue.GetMediaQueueItemsListener() {
@Override
public void onItemsSuccess(List<MediaQueueItem> list) {
}
@Override
public void onError(MediaQueue.Error error) {
}
});
Parameters:
pagingOption - PagingOption If not specified, it returns all the items
2. getQueueItemCount() The method is used to get the count of items available in the media queue
Return:
It returns the number of items available in the media queue
3. getCurrentQueueItemIndex()
The method is used to get the index position for the current media item
Return:
It returns the index value of the current media item
4. getPlaybackState()
The method used to get the playback state of the queue. Playback states include paused, playing, stopped, and unknown.
Return:
The value is defined in the MediaQueue.PlaybackState enum
5. getSubtitleCode()
The method used to get the default ISO 639-2 language code for the subtitles in the media queue.
Return:
It returns the ISO code of the default subtitle
6. getSubtitleType
The method used to get the default subtitle type
Return:
It returns the default subtitle type of media queue e.g. embedded, description, etc.
7 . getSoundtrackCode()
The method used to get the default ISO 639-2 language code for the soundtrack in the media queue.
Return:
It returns the default soundtrack ISO code
8 . getSoundtrackType()
The method used to get the default soundtrack type of the media queue
Return:
It returns the default soundtrack type
9 . getRepeatMode()
The method used to get the repeat mode for the media queue. The values are All to repeat all the items, None to not repeat the media queue, One to repeat only the current item, or Unknown.
Returns:
It returns the RepeatModeType enum value
10. getLastUpdated()
The method used to get the last timestamp for the media queue.
Return:
It returns the last timestamp for the media queue.
11. hasNext()
The method determines whether the media queue has a next item.
Return:
It returns true if the current playlist item has a next media item, otherwise false
12 . hasPrev()
The method determines whether the media queue has a previous item.
Returns:
It returns true if the current playlist item has a previous media item, otherwise false
13. getShuffleMode()
The method determines the status of shuffle mode
Return:
It returns true if shuffle mode is enabled, otherwise false
Listeners/Notifications#
1. public void setMediaQueueChangeListener(MediaQueue.MediaQueueChangeListener listener)
The method used to set the media queue change listener. The listener is invoked once the media queue change is received. This can be invoked when items are added or removed. MediaQueue.getItems(PagingOption, GetMediaQueueItemsListener) can be called to get items.
mediaQueue.setMediaQueueChangeListener(new MediaQueue.MediaQueueChangeListener() {
@Override
public void onMediaQueueItemsChanged(JSONObject jsonObject) {
}
});
Parameter:
listener: The object of MediaQueue.MediaQueueChangeListener, contains onMediaQueueItemsChanged method. The method is invoked when changes are happening in the media queue.
2. public void setMediaQueueCurrentIndexChangeListener(MediaQueue.MediaQueueIndexChangeListener listener)
The method used to set the media queue Item Index change listener. The listener is invoked once the media queue index is changed.
mediaQueue.setMediaQueueCurrentIndexChangeListener(new MediaQueue.MediaQueueIndexChangeListener() {
@Override
public void onMediaQueueCurrentIndexChanged(int i) {
}
});
Parameter:
listener: The object of MediaQueue.MediaQueueIndexChangeListener. It contains the onMediaQueueCurrentIndexChanged, which provides the changed index of the media queue.
3 . public void setMediaQueuePlaybackStateChangeListener(MediaQueue.MediaQueuePlaybackStateChangeListener listener)
The method used to set the media queue playback state changes the listener. The listener is invoked once the media queue playback state changes the listener.
mediaQueue.setMediaQueuePlaybackStateChangeListener(new MediaQueue.MediaQueuePlaybackStateChangeListener() {
@Override
public void onMediaQueuePlaybackStateChanged(MediaQueue.PlaybackState playbackState) {
}
});
Parameter:
listener: The object of MediaQueue.MediaQueuePlaybackStateChangeListener. It contains the onMediaQueuePlaybackStateChanged method, invoked whenever the play state changes.
The method provides the playback state that is defined in MediaQueue.PlaybackState enum
4 . public void setMediaQueueSubtitleChangeListener(MediaQueue.MediaQueueSubtitleChangeListener listener)
The method used to set media queue subtitle change listener. The listener is invoked once the default subtitle is changed.
mediaQueue.setMediaQueueSubtitleChangeListener(new MediaQueue.MediaQueueSubtitleChangeListener() {
@Override
public void onMediaQueueSubtitleChanged(String s, String s1) {
}
});
Parameter :
listener: The object of MediaQueue.MediaQueueSubtitleChangeListener. It contains the onMediaQueueSubtitleChanged method, which calls whenever the default subtitle of the media queue is changed.
This method provides two parameters i.e. the ISO code of the default subtitle and the type of subtitle.
5. public void setMediaQueueSoundtrackChangeListener(MediaQueue.MediaQueueSoundtrackChangeListener listener)
The method used to set the media queue soundtrack changes the listener. The listener is invoked once the default soundtrack is changed.
mediaQueue.setMediaQueueSoundtrackChangeListener(new MediaQueue.MediaQueueSoundtrackChangeListener() {
@Override
public void onMediaQueueSoundtrackChanged(String s, String s1) {
}
});
Parameter :
listener: The object of MediaQueue.MediaQueueSoundtrackChangeListener. It contains the onMediaQueueSoundtrackChanged method, which calls whenever the default soundtrack of the media queue is changed.
This method provides two parameters, i.e., the default soundtrack's ISO code and the soundtrack's type.
6 . public void setMediaQueueShuffleModeChangeListener(MediaQueue.MediaQueueShuffleModeChangeListener listener)
The method used to set the media queue shuffle mode changes the listener. The listener is invoked whenever the shuffle mode changes using the setShuffleMode method or changes from the PED. If the shuffle mode is the same then this listener is not invoked
mediaQueue.setMediaQueueShuffleModeChangeListener(new MediaQueue.MediaQueueShuffleModeChangeListener() {
@Override
public void onMediaQueueShuffleModeChanged(boolean b) {
}
});
Parameter:
listener: The object of MediaQueue.MediaQueueShuffleModeChangeListener. The listener invoked the onMediaQueueShuffleModeChanged method. The method returns the boolean value based on the status of shuffle mode.
7. public void setMediaQueueRepeatModeChangeListener(MediaQueue.MediaQueueRepeatModeChangeListener listener)
The method used to set the media queue repeat mode change listener. The listener is invoked whenever the repeat mode is changed using setRepeatMode or from the PED. if the repeat mode is the same, then this method will not invoked
mediaQueue.setMediaQueueRepeatModeChangeListener(new MediaQueue.MediaQueueRepeatModeChangeListener() {
@Override
public void onMediaQueueRepeatModeChanged(MediaQueue.RepeatModeType repeatModeType) {
}
});
Parameter:
listener: The object of MediaQueue.MediaQueueRepeatModeChangeListener. The listener contains the onMediaQueueRepeatModeChanged method. It provides the value that is defined in the RepeatModeType enum
8. public void setMediaQueueHasNextPrevChangeListener(MediaQueue.MediaQueueHasNextPrevChangeListener listener)
mediaQueue.setMediaQueueHasNextPrevChangeListener(new MediaQueue.MediaQueueHasNextPrevChangeListener() {
@Override
public void onMediaQueueHasNextPrevChanged(boolean b, boolean b1) {
}
});
The method to set the media queue has the next or previous change listener. The listener is invoked whenever the has next or has previous value changes.
Parameter:
listener: The object of MediaQueue.MediaQueueHasNextPrevChangeListener. The listener contains the onMediaQueueHasNextPrevChanged method. This method provides two boolean values that are hasPrevious and hasNext
Version 1.0