Skip to content

Android Seat bookmark#

The Bookmark functionality within the Inflight Android Seatback SDK User Module allows users to save and manage specific content for later access. This is especially useful in an inflight entertainment system where passengers may want to resume a movie, TV show, or other media content from where they left off.

This document provides coverage of the V2 API for the bookmark functionality.

1. Initialize the Bookmark#

The Bookmarks class has a static method called initService with the help of this method, we can start operation on the bookmark after the successful initialization onInitServiceComplete method provides the bookmark object. This bookmark object is used for further operations.

private Bookmarks bookmarks;
Bookmarks.initService(this, new IInFlightCallback() {
    @Override
    public void onInitServiceComplete(Object o, String s) {
        bookmarks = (Bookmarks) o;
        if (bookmarks != null) {
            Log.v(TAG, "initialize bookmarks succeed.");
        }
        else {
            Log.e(TAG, "initialize bookmarks failed.");
        }
    }

    @Override
    public void onInitServiceFailed(String s, InFlight.Error error) {
        Log.e(TAG, "initialize bookmarks failed.");
    }
}, new InFlight());

2. Set the listener to listen to the updates#

The Bookmarks class includes a method called setSyncListener, which is used to register a listener of type Sync.SyncListener. This listener is responsible for providing real-time updates whenever a passenger adds a bookmark through a Passenger Electronic Device (PED) or any other In-Flight Entertainment (IFE) component.

The Sync.SyncListener offers several callback methods to handle different synchronization events:

  • onUserDataChanged – Triggered when a user's bookmark data is modified.

  • onConflict – Invoked when a synchronization conflict occurs, requiring resolution.

  • onSyncFinished – The method is invoked upon the successful completion of the synchronization process and returns a Date object that represents the timestamp of the last synchronization.

  • onSyncFailed – Executed if the synchronization process encounters an error.

bookmarks.setSyncListener(new Sync.SyncListener() {
    @Override
    public void onUserDataChanged() {
        Log.v(TAG, "onUserDataChanged()");
    }

    @Override
    public void onConflict(List<? extends ConflictItem> list) {
        Log.v(TAG, "onConflict(): "+list);
    }

    @Override
    public void onSyncFinished(Date date) {
        Log.v(TAG, "onSyncFinished()");
    }

    @Override
    public void onSyncFailed(SyncError syncError) {
        Log.v(TAG, "onSyncFailed()");
    }
}

3. Various bookmark operations#

The bookmarks class has various methods to get, add, remove, and clear bookmark

3.1. Get a list of bookmark

We have a method called getItems to get the bookmark items, which returns the Map>. The map's key is mediaUri and the value is a list of an associated bookmark. We can create multiple bookmarks for the single media item with different elapsed time.

public Map<String,List<Bookmark>> getItems()

Example:

Map<String, List<Bookmark>> items = bookmarks.getItems();

The provided code demonstrates the process of retrieving the bookmark list. The method returns a Map data structure, where:

  • The key in the map represents the media URI, which uniquely identifies a piece of media content.

  • The value associated with each key is a list of bookmarks corresponding to that specific media URI.

3.2 Add the bookmark

The add method is used to insert a bookmark into the list. A new bookmark is appended to the end of the list unless an entry with the same media URI and elapsed time already exists, in which case it is not added. The method returns true if the bookmark is successfully added; otherwise, it returns false.

public boolean add(Bookmark bookmark) throws UserOperationException

Parameters:

  • bookmark - The bookmark that will be added to the list.

Example:

SeatBookmark seatBookmark = new SeatBookmark();
seatBookmark.setMediaUri(mediaUri.getText().toString());
seatBookmark.setParentMediaUri(mediaUri.getText().toString());
seatBookmark.setElapsedTime(Long.parseLong(elapsedTime.getText().toString()));
seatBookmark.setSubtitleCode(subtitleCode.getText().toString());
seatBookmark.setSoundtrackCode(soundtrackCode.getText().toString());
bookmarks.add(seatBookmark);

In the given example, the SeatBookmark object is initialized and configured by setting various required fields. These fields include:

  • Media URI – The unique identifier for the media content.

  • Parent URI – The identifier of the parent media, if applicable.

  • Elapsed Time – The playback position at which the bookmark is created.

  • Soundtrack Code – The code representing the selected audio track for the media

  • Subtitle Code – The code representing the selected subtitle language

Once all necessary information is assigned to the SeatBookmark object, the add method of the Bookmarks class must be invoked to save the bookmark.

3.3 Remove the bookmark

3.3.1 Remove by using the bookmark item

An overloaded method is available to remove bookmarks from the list. This method allows bookmarks to be removed using bookmark objects. It returns true if the specified bookmark is successfully removed from the list; otherwise, it returns false. Both the method throws the UserOperationException.

public boolean remove(Bookmark bookmark)throws UserOperationException

Parameters:

  1. Bookmark - The specific bookmark object that is designated for removal. This object contains details such as the media URI, elapsed playback time, and other relevant metadata.

Example:

bookmarks.remove(bookmarkItem);

In the given example, the bookmark object is provided, containing details such as the media URI, elapsed time, and other relevant information.

3.3.2 Remove the bookmark by using the media Uri

The overloaded remove method removes a bookmark based on the specified media URI. It returns true if the bookmark is successfully removed; otherwise, it returns false.

public boolean remove(String mediaUri)throws UserOperationException

Parameters:

  • String mediaUri - The media URI of the bookmark that is to be removed from the list.

Example:

bookmarks.remove("media_uri");

In the given example, the media URI of the specific media item is passed as a parameter to the remove method. This method attempts to locate and delete the corresponding bookmark associated with the provided media URI. Upon execution, it returns a boolean value, indicating whether the removal was successful. If the bookmark is found and removed, the method returns true; otherwise, it returns false if no matching entry exists in the bookmark list.

3.4 Clear bookmark list

To remove all bookmarks from the list, the Bookmarks class provides a method named Clear. This method effectively deletes all stored bookmarks and does not return any value upon execution. Additionally, the Clear method ensures that bookmarks are removed from the PMD.

It is not necessary to manually invoke the Clear method after flight close, as the paxus_client component automatically handles bookmark removal at the end of the sector.

public void clear() throws UserOperationException

Example

bookmarks.clear();

The given code is responsible for deleting all saved bookmarks.

4. Bookmark conflicts and resolving methods#

4.1 Set conflict strategy

This method is used to define the conflict strategy, during synchronization between the Passenger Entertainment Device (PED) and the seatback monitor. When both devices attempt to update bookmark data simultaneously, inconsistencies may arise due to differences in stored playback positions. The In-Flight Entertainment (IFE) system resolves conflicts according to the chosen conflict resolution strategy. There are two distinct types of conflict resolution strategies,

  1. KEEP_LATEST - If application developers prefer the SDK to manage conflicts automatically, they can specify the KEEP_LATEST option. The SDK resolves conflicts when this option is enabled by selecting the most recently updated data. As a result, conflicts within the specified dataset are handled internally by the SDK, ensuring that the latest changes are retained without triggering any conflict notifications in the application.

  2. USER_DEFINED - If application developers prefer to manage conflicts manually, they can specify the USER_DEFINED option. With this setting, the SDK triggers the onConflict(List) method of Sync.SyncListener(), provides a list of conflicts within the application for the specified dataset. Developers must then manually resolve each conflict by invoking the resolveConflict() method on individual conflict items. Once all conflicts have been addressed, the SDK proceeds with synchronization. The available conflict resolution strategies define how these conflicts can be managed effectively.

public void setConflictStrategy(ConflictStrategy strategy)

Example

bookmarks.setConflictStrategy(ConflictStrategy.KEEP_LATEST);

In the example above, the conflict strategy is set to KEEP_LATEST. The Bookmark class includes the setConflictStrategy method, which is used to define the bookmark strategy.

4.2 Get a List of conflicts

public List<BookmarkConflictItem> getConflicts()

This method is responsible for retrieving a list of conflicts that arise during the synchronization of bookmarks. It returns a list of BookmarkConflictItem objects, where each item represents an individual conflict.

Each BookmarkConflictItem contains:

  • A Map that holds both the Local Bookmark (the bookmark stored on the current device) and the Remote Bookmark (the bookmark received from the IFE server).

  • A method that allows the resolution of conflicts using user-defined techniques.

Four conflict resolution methods are available, each providing a different approach to handling discrepancies between the local and remote bookmark data.

These four conflict resolution strategies are defined using the ConflictResolution enumeration, and they are

  1. LOCAL_CONFLICT - Select the locally stored item to resolve the conflict.
  2. MERGE_DUPLICATE - Combines the conflicting items using the duplicate handling mode.
  3. MERGE_UNIQUE - Combines the conflicting items using the unique entry mode.
  4. REMOTE_CONFLICT - Select the remotely stored item to resolve the conflict.

4.3 Resolve Conflict

The BookmarkConflictItem class includes the resolveConflict method, responsible for resolving conflicts between local and remote bookmarks.

List<BookmarkConflictItem> bookmarkConflictItemList = bookmarks.getConflicts();
for (BookmarkConflictItem item : bookmarkConflictItemList) {
    Map<String,List<Bookmark>> localBookmarks = item.getLocalBookmarks();
    Map<String,List<Bookmark>> remoteBookmark = item.getRemoteBookmarks();
    item.resolveConflict(ConflictResolution.LOCAL_CONFLICT);
}

In the example above, the list of BookmarkConflictItem objects is retrieved using the getConflicts method of the Bookmarks class. This method provides both the local and remote bookmarks. The BookmarkConflictItem class also includes the resolveConflict method, which resolves conflicts using the specified conflict resolution option. In this case, LOCAL_CONFLICT is selected to resolve the conflict.

Version 1.0