Android Metadata#
The document provides a comprehensive guide to the Metadata SDK's V2 API, which supports both Ground mode and Air mode. It explains how to use metadata in each mode, covering key functionalities and differences. While the APIs work similarly in both modes, the initialization process varies depending on the environment.
1. How to identify whether it is in Ground or Air mode?#
The inflight SDK offers a Service Discovery API, which determines whether a passenger's electronic device is connected to the Ground server (Internet) or the Air server (inflight entertainment system).
InFlight mInFlight = new InFlight();
// Initialization of Service Discovery
ServiceDiscoveryV1.initService(getActivity(), new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
// Initialization is successful
if (o instanceof ServiceDiscoveryV1) {
mServiceDiscoveryV1 = (ServiceDiscoveryV1) o;
// Check the server availability
boolean isAvailable = mServiceDiscoveryV1.isServerAvailable();
// If isAvailable true it means that PED is in Air mode
// else means that server is connected with Ground server
} else {
Log.e(TAG, "initiate ServiceDiscoveryV1 failed.");
}
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
Log.e(TAG, "onInitServiceFailed(): " + error);
}
}, mInFlight);
The example above illustrates the process of determining whether the application is operating in Ground mode or Air mode. After successfully initializing the Service Discovery, the isServerAvailable method should be called. If this method returns true, it indicates that the PED (Passenger Electronic Device) is connected to the Air server. Conversely, if it returns false, it signifies that the device is connected to the Ground server. This check helps ensure that the application interacts with the appropriate metadata source based on the current mode.
2. Initialization of Metadata services#
2.1. Initialization of Metadata service to get data on the ground**#
private GroundMetadata groundMetadata;
// Inflight object initialization
InFlight mInFlight = new InFlight();
// Configuring the app ID, which is only required in Ground mode.
mInFlight.setAppId(this, "asdfghjkl2cv45678iuhjtyhfghkmnhtfcd355yhfvcrefccrgthtcg");
GroundMetadata.initService(V2GroundMetadataAPITestActivity.this, new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
// GroundMetadata service initialized succssfully
groundMetadta = (GroundMetadata) o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
// Error in initialzation of ground metadata service
}
}, mInFlight);
The first step in accessing ground metadata is initialization. Upon successful initialization, a GroundMetadata object is provided. Additionally, an app ID is required, which will be provided by the Panasonic focal. This app ID is essential for authentication and accessing airline-specific metadata stored on the ground server.
2.2 Initialization of Metadata service to get data in the air mode#
private Metadata mMetadata;
private InFlight mInFlight = new InFlight()
Metadata.initService(V2AsynAPITestActivity.this, new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
// On Succesfully initialization metadata object will be obtained
mMetadata = (Metadata)o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
// Method get called if any occured during initilization
}
}, mInFlight);
3. One-time configuration#
3.1. Set Seat Class#
The Metadata API delivers data based on seat class, with different seat types offering distinct media. This method sets the seat class and retrieves class-specific media metadata.
Example
The SeatClass class includes various seat class names; use the provided class names to prevent errors.
3.2. Set Language#
Sets the 3-letter ISO 639-2 language code. If this method is invoked, the specified language will be used. Otherwise, the passenger's device default language will be applied. In both scenarios, all language-specific fields are returned in the specified language if available. If not, the airline's default language is used.
Example
3.3. Set Frequentflier Tier#
If this parameter is provided, media_uris will include media items assigned to the specified frequent_flyer_tier, regardless of the seat_class. For example, a passenger with the frequent_flyer_tier "LPPS" seated in Economy class will have access to all media items assigned to "LPPS," even if some are typically available only in First class.
Example
3.4. Set Flight Identifiers Attributes (applicable in the Ground mode only)#
The method sets various flight attributes like travel date, origin, destination, tail number, flight number, and aircraft type. The method accepts the FlightIdentifierAttrs object
The FlightIdentifierAttrs class contains several properties that need to be configured before calling any ground metadata API; otherwise, the GroundMetadata API will fail to function.
| 1 | Travel Date | The date of travel of the particular flight. |
|---|---|---|
| 2 | Origin | The origin of the flight. It is case-insensitive 3 letter IATA code. I.e. “LAX”, “jfk”. |
| 3 | Destination | The destination of the flight. It is case-insensitive 3 letter IATA code. I.e. “LAX”, “jfk”. |
| 4 | Tail Number | The aircraft’s tail number. |
| 5 | Aircraft Type | The aircraft type. |
| 6 | Flight Number | The flight number. |
Example
//Configuration of Flight Identifier attributes
String dateString = "2024-01-31";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date travelDate = formatter.parse(dateString);
FlightIdentifierAttrs mFlightIdentifierAttrs = new FlightIdentifierAttrs(travelDate,"PNQ","BOM","682","ABC-123","type");
//Setting flight identifiers to ground metadata
groundMetadata.setFlightIdentifierAttributes(mFlightIdentifierAttrs)
4. Asynchronous vs Synchronous API Call#
The metadata module provides two types of APIs: synchronous and asynchronous.
-
Synchronous API calls are blocking calls, meaning they will halt the execution of the program until the response is received. It is important not to invoke synchronous API calls from the UI thread to avoid freezing the user interface.
-
Asynchronous API calls, on the other hand, return data through callbacks, allowing the program to continue running while waiting for the response. Each asynchronous API call returns a request object with two methods:
- executeAsync: This method is used to initiate the API call.
- cancel: This method stops the execution of the API call if it has already been started using executeAsync.
5. Advanced Metadata API#
Advanced Metadata provides a set of APIs that enable advanced features like paging and fuzzy search, enhancing the flexibility and efficiency of data retrieval. These advanced features are available exclusively in AIR mode. The Advanced Metadata API is designed to function in both synchronous and asynchronous modes, offering developers the option to choose the most suitable approach for their needs.
6. Get Categories List#
Metadata provides multiple methods to fetch media categories that allow developers to retrieve a list of categories and subcategories. These methods support both full category retrieval and filtered queries based on root categories and seat class filters.
6.1 Synchronous Call#
public List<Category> getCategoriesWithRootCategory(String seatClass,
String rootCategory)
throws Metadata.MetadataException
Note: Avoid calling this method from the UI thread, as it is a blocking operation.
-
Parameter
-
seatClass - Sets the seat class, such as First or Economy, with values defined in
SeatClass.- If null, the seat class specified by setSeatClass(String) is used.
- If setSeatClass(String) is never called, SeatClass.ALL is applied.
-
rootCategory - Root category for the category listing. Root Category values are in
Metadata.RootCategory
-
Example
try {
List<Category> categoryList = mMetadataV2.getCategoriesWithRootCategory(SeatClass.PREMIUM_ECONOMY, Metadata.RootCategory.MOVIES);
} catch (Metadata.MetadataException e) {
Log.e(TAG,e.toString());
}
In the example above, the Seat class is Premium Economy, and the root category is Movies. The method returns a List<Category> and operates synchronously. Avoid calling this method from the main thread. The method also throws the Metadata exception.
6.2 Asynchronous Call#
public RequestCategory getCategoriesWithRootCategory(String seatClass,
String rootCategory,
Metadata.OnCategoryListReceivedListener onCategoryListReceivedListener)
- Parameter
- seatClass - Sets the seat class, such as First or Economy, with values defined in
SeatClass.- If null, the seat class specified by setSeatClass(String) is used.
- If setSeatClass(String) is never called, SeatClass.ALL is applied.
- rootCategory - Root category for the category listing. Root Category values are in
Metadata.RootCategory - Metadata.OnCategoryListReceivedListener - The callback function will be called once the request is successfully processed and returns the category data with a List
format and the Request
- seatClass - Sets the seat class, such as First or Economy, with values defined in
Example
RequestCategory requestCategory = mMetadataV2.getCategoriesWithRootCategory(SeatClass.BUSINESS, "movies", new Metadata.OnCategoryListReceivedListener() {
@Override
public void onCategoryListReceived(List<Category> list, Request request) {
// On successful call of method a List of category obtained
}
@Override
public void onMetadataError(Metadata.Error error) {
// Invoked this when any error trigger during method call
}
});
// Call the below method get data
requestCategory.executeAsync();
In the method above, the seat class is Business, and the root category is Movies. Additionally, an OnCategoryListReceivedListener must be provided. The callback returns a list of categories. The method returns a RequestCategory object, which includes the executeAsync method that must be explicitly called to retrieve the data.
6.3. Advanced metadata synchronous call#
public AdvancedCategoryResponse getCategoriesWithRootCategory(String seatClass,
String rootCategory,
CategoryRequestAttrs categoryAttrs)
throws Metadata.MetadataException
-
Parameter
- seatClass - Sets the seat class, such as First or Economy, with values defined in
SeatClass.- If null, the seat class specified by setSeatClass(String) is used.
- If setSeatClass(String) is never called, SeatClass.ALL is applied.
- rootCategory - Root category for the category listing. Root Category values are in the
Metadata.RootCategory - CategoryRequestAttrs - The parameter is used to configure pagination and pass a list of blocked MIDs, ensuring those media items are excluded from the callback results.
- seatClass - Sets the seat class, such as First or Economy, with values defined in
-
Return Type
- AdvanceCategoryResponse - It contains the list of Category and Pagination option objects.
Note: Avoid calling this method from the UI thread, as it is a blocking operation.
Example
CategoryRequestAttrs categoryRequestAttrs = new CategoryRequestAttrs();
PagingOption pagingOption = new PagingOption(10,2);
categoryRequestAttrs.setPagingOption(pagingOption);
try {
AdvancedCategoryResponse advancedCategoryResponse = mMetadataV2.getAdvancedMetadata().getCategoriesWithRootCategory(SeatClass.FIRST, Metadata.RootCategory.MOVIES, categoryRequestAttrs);
List<Category> categoryList = advancedCategoryResponse.getCategories();
AdvancedCategoryResponse.PagingResponse responsePaginationResponse = advancedCategoryResponse.getPagingResponse();
} catch (Metadata.MetadataException e) {
//Metadata error
}
In the example above, the seat class is First, and the root category is Movies. Additionally, CategoryRequestAttr is provided, with PaginationOption configured. The offset value and page size are set using PaginationSet. The method returns an AdvancedCategoryResponse object, which includes a list of categories and an AdvancedCategoryResponse.PagingResponse.
6.4. Advanced metadata asynchronous call#
public RequestCategory getCategoriesWithRootCategory(String seatClass,
String rootCategory,
CategoryRequestAttrs categoryAttrs,
Metadata.OnAdvancedCategoryListReceivedListener onAdvancedCategoryListReceivedListener)
- Parameter
- seatClass - Sets the seat class, such as First or Economy, with values defined in
SeatClass.- If null, the seat class specified by setSeatClass(String) is used.
- If setSeatClass(String) is never called, SeatClass.ALL is applied.
- rootCategory - Root category for the category listing. Root Category values are in
Metadata.RootCategory - CategoryRequestAttrs - The parameter is used to configure pagination and pass a list of blocked MIDs, ensuring those media items are excluded from the callback results.
- Metadata.OnCategoryListReceivedListener - The callback function will be called once the request is successfully processed and returns the category data with a List
format and the Request
- seatClass - Sets the seat class, such as First or Economy, with values defined in
Example
CategoryRequestAttrs categoryRequestAttrs = new CategoryRequestAttrs();
PagingOption pagingOption = new PagingOption(10,2);
categoryRequestAttrs.setPagingOption(pagingOption);
RequestCategory requestCategory = mMetadataV2.getAdvancedMetadata().getCategoriesWithRootCategory(SeatClass.FIRST, Metadata.RootCategory.MOVIES, categoryRequestAttrs,
new Metadata.OnAdvancedCategoryListReceivedListener() {
@Override
public void onCategoryListReceived(AdvancedCategoryResponse advancedCategoryResponse, Request request) {
List<Category> categoryList = advancedCategoryResponse.getCategories();
AdvancedCategoryResponse.PagingResponse pagingResponse = advancedCategoryResponse.getPagingResponse();
}
@Override
public void onCategoryListReceived(List<Category> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
}
});
requestCategory.executeAsync();
This example is similar to the one in Section 6.3, with the addition of Metadata.OnAdvancedCategoryListReceivedListener(). This listener is used to retrieve data after a successful API call. The onCategoryListReceived method returns a list of categories along with an AdvancedCategoryResponse.PagingResponse. The method returns a RequestCategory object, which includes the executeAsync method that must be called to initiate the API request and fetch the data.
7. Retrieving the Media List with Category#
After retrieving media categories using the methods, developers can fetch media metadata using the category ID. The following methods allow querying media lists for specific categories or multiple categories simultaneously. This enables passengers to conveniently browse available movies, TV shows, or music based on their preferences and seat class
7.1. Synchronous call#
public List<MediaItem> getCategoryMediaByCategoryId(String categoryId,
String seatClass,
Set<String> selectedFields)
throws Metadata.MetadataException
-
Parameter
- categoryId - Category ID of the media
- seatClass - Sets the seat class, such as First or Economy, with values defined in SeatClass.
- selectedFields - Specifies the set of fields to be included in the response. If a specific list of fields is provided, only those fields will be returned. However, if this parameter is set to null, the response will include all available fields by default.
-
Return type
- The API returns a List of MediaItem
Example
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("soundtrack");
requestFields.add("subtitle");
try {
List<MediaItem> mediaItemList = mMetadataV2.getCategoryMediaByCategoryId("121",SeatClass.ECONOMY,requestFields);
} catch (Metadata.MetadataException e) {
throw new RuntimeException(e);
}
In the example above, the category ID is set to 121, and the seat class is specified as Economy. The requested field is defined as a set of string values, meaning only the specified fields will be included in the response. This ensures that the response contains only the necessary data, optimizing performance and reducing unnecessary payload. The method returns a List<MediaItem>, where each MediaItem represents an individual media entity that matches the requested criteria.
7.2. Asynchronous call#
public RequestCategoryMedia getCategoryMediaByCategoryId(String categoryId,
String seatClass,
Set<String> selectedFields,
Metadata.OnMediaItemListReceivedListener categoryMediaResponseListener)
-
Parameter
- categoryId - Category ID of the media
- seatClass - Sets the seat class, such as First or Economy, with values defined in SeatClass.
- selectedFields - Specifies the set of fields to be included in the response. If a specific list of fields is provided, only those fields will be returned. However, if this parameter is set to null, the response will include all available fields by default.
-
Return type
- As an object of RequestCategoryMedia, we need to call the
executeAsyncmethod to get data asynchronously
- As an object of RequestCategoryMedia, we need to call the
Example
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("soundtrack");
requestFields.add("subtitle");
requestFields.add("actor");
RequestCategoryMedia requestCategoryMedia = mMetadataV2.getCategoryMediaByCategoryId("100", SeatClass.ECONOMY, requestFields, new Metadata.OnMediaItemListReceivedListener() {
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
// Getting list of mediaItem
}
@Override
public void onMetadataError(Metadata.Error error) {
// Invoke when any error occur during API call
}
});
requestCategoryMedia.executeAsync();
In the example above, the media category ID is set to 100, and the seat class is Economy. Additionally, the requested fields are specified as a set, including title, soundtrack, subtitle, and actor. To handle the API response, an OnMediaItemListReceivedListener must be provided. The method returns a RequestCategoryMedia object, which includes the executeAsync method that must be called to initiate the request and retrieve the data.
7.3. Advance metadata synchronous call#
public MediaResponse getCategoryMediaByCategoryId(String categoryId,
String seatClass,
Set<String> selectedFields,
CategoryMediaRequestAttrs categoryMediaAttrs)
throws Metadata.MetadataException
-
Parameter
- categoryId - Category ID of the media
- seatClass -Sets the seat class, such as First or Economy, with values defined in SeatClass.
- selectedFields - Specifies the set of fields to be included in the response. If a specific list of fields is provided, only those fields will be returned. However, if this parameter is set to null, the response will include all available fields by default.
- categoryMediaAttrs - The parameter is used to configure pagination and pass a list of blocked MIDs, ensuring those media items are excluded from the callback results.
-
Return type
- MediaResponse - The Media Response object contains a List<MediaItem> and pagination data.
Example
CategoryMediaRequestAttrs categoryRequestAttrs = new CategoryMediaRequestAttrs();
PagingOption pagingOption = new PagingOption(0,20);
categoryRequestAttrs.setPagingOption(pagingOption);
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("actor");
requestFields.add("year");
try {
MediaResponse mediaResponse = mMetadataV2.getAdvancedMetadata().getCategoryMediaByCategoryId("121", SeatClass.ECONOMY, requestFields, categoryRequestAttrs);
} catch (Metadata.MetadataException e) {
throw new RuntimeException(e);
}
In the example above, the category ID is set to 121, and the seat class is Economy. Additionally, the requested fields include title, actor, and year. The CategoryMediaAttributes object contains pagination details, with an offset of 0 and a page size of 20, ensuring that the first 20 items are retrieved. The method returns a MediaResponse containing a list of MediaItem objects and pagination options. It may throw a MetadataException, so it must be handled within a try-catch block.
7.4. Advanced metadata asynchronous call#
public RequestCategoryMedia getCategoryMediaByCategoryId(String categoryId,
String seatClass,
Set<String> selectedFields,
CategoryMediaRequestAttrs categoryMediaAttrs,
Metadata.OnAdvancedMediaResponseListReceivedListener onAdvancedMediaResponseListReceivedListener)
- Parameter
- categoryId - Category ID of the media
- seatClass - Sets the seat class, such as First or Economy, with values defined in SeatClass.
- selectedFields - Specifies the set of fields to be included in the response. If a specific list of fields is provided, only those fields will be returned. However, if this parameter is set to null, the response will include all available fields by default.
- categoryMediaAttrs - The parameter is used to configure pagination and pass a list of blocked MIDs, ensuring those media items are excluded from the callback results.
- Return type
- RequestCategoryMedia - An object of RequestCategoryMedia, we need to call the
executeAsyncmethod to get data asynchronously.
- RequestCategoryMedia - An object of RequestCategoryMedia, we need to call the
Example
CategoryMediaRequestAttrs categoryRequestAttrs = new CategoryMediaRequestAttrs();
PagingOption pagingOption = new PagingOption(0,20);
categoryRequestAttrs.setPagingOption(pagingOption);
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("actor");
requestFields.add("year");
RequestCategoryMedia requestCategoryMedia = mMetadataV2.getAdvancedMetadata().getCategoryMediaByCategoryId("121", SeatClass.ECONOMY, requestFields, categoryRequestAttrs, new Metadata.OnAdvancedMediaResponseListReceivedListener() {
@Override
public void onAdvancedMediaResponseListReceived(MediaResponse mediaResponse, Request request) {
List<MediaItem> mediaItemList = mediaResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaResponse.getPagingResponse();
}
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
}
});
requestCategoryMedia.executeAsync();
In the example above, the category ID is set to 121, and the seat class is Economy, meaning the response will include a list of all items that belong to category ID 121 and are available for the Economy class. Additionally, pagination options are specified in CategoryMediaRequestAttr, with an offset of 0 and a page size of 20, ensuring that the first 20 items are retrieved in the response. The method returns a RequestCategoryMedia object, and the executeAsync method must be explicitly called to initiate the request and fetch the data.
Similar APIs are available to retrieve data based on multiple category IDs, requiring a list of category IDs instead of a single one.
8. Retrieving Child Media#
After retrieving a media list, developers can obtain child media items using the parent media URI from the response. Child media refers to content organized under a parent entity, such as songs within an album (where the album acts as the parent) or episodes within a TV series (where the series serves as the parent media).
Passengers can explore music albums to access individual songs or browse TV series to select specific episodes.
8.1. Synchronous call#
public List<MediaItem> getChildMediaByAggregateMediaUri(String mediaUri,
Set<String> selectedFields)
throws Metadata.MetadataException
- Parameter
- mediaUri - Media data URI, which is returned by
- selectedFields - Specifies the fields to return. If null, all fields will be returned.
- Return Type
- List<MediaItem> - The API provides a list of MediaItem.
Example
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("duration");
try {
List<MediaItem> childMediaItemList = mMetadataV2.getChildMediaByAggregateMediaUri("mediaL:abc323",requestFields);
} catch (Metadata.MetadataException e) {
//Exception during api call
}
In the example above, a media URI for a TV series is provided to retrieve a list of TV episodes. Only the title and duration are requested, rather than fetching all details of the child items. The method returns a List<MediaItem> and may throw a MetadataException, which should be handled appropriately.
8.2. Asynchronous call#
public RequestMediaAggregate getChildMediaByAggregateMediaUri(String mediaUri,
Set<String> selectedFields,
MediaItemRequestAttrs mediaAttrs,
Metadata.OnMediaItemListReceivedListener mediaAggregateResponseListener)
- Parameter
- mediaUri - Media data URI, which is returned by
- selectedFields - Specifies the fields to return. If null, all fields will be returned.
- mediaAttrs - MediaItemRequestAttrs
- mediaAggregateResponseListener - Metadata.Listener: This callback will be invoked in the context of the calling thread
Example
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("duration");
RequestMediaAggregate mediaAggregate = mMetadataV2.getChildMediaByAggregateMediaUri("mediaL:abc323", requestFields,
new Metadata.OnMediaItemListReceivedListener() {
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
//List of media item received
}
@Override
public void onMetadataError(Metadata.Error error) {
//Invoke the method when any error occurred during the API Call
}
});
mediaAggregate.executeAsync();
In the example above, a request is made to retrieve a list of child items from a TV series, with the focus on fetching only specific fields such as the title and duration, rather than retrieving all available details of each child item. This helps optimize the response by limiting the data to just the necessary information.
The response is handled through the OnMediaItemListReceivedListener, which listens for the API call results and processes the data once it's returned. The method returns a RequestMediaAggregate object, which acts as a wrapper for the API request. To trigger the actual request and retrieve the data, the executeAsync method on the RequestMediaAggregate object must be explicitly called. This method performs the asynchronous API call and returns the required data once completed.
8.3. Advanced Metadata Synchronous call#
public MediaResponse getChildMediaByAggregateMediaUri(String mediaUri,
Set<String> selectedFields,
MediaItemRequestAttrs mediaAttrs)
throws Metadata.MetadataException
- Parameter
- mediaUri - Media data URI, which is returned by #getCategoryMediaByCategoryId(String,String,Set, OnMediaItemListReceivedListener )
- selectedFields - Specifies the fields to return. If null, all fields will be returned.
- mediaAttrs - The parameter is used to configure pagination and pass a list of blocked MIDs, ensuring those media items are excluded from the callback results.
- mediaAggregateResponseListener - Metadata.Listener: This callback will be invoked in the context of the calling thread.
- Return Type
- MediaResponse - An object that contains a list of MediaItem and PaginationResponse.
MediaItemRequestAttrs mediaItemRequestAttrs = new MediaItemRequestAttrs();
PagingOption pagingOption = new PagingOption(11, 20);
mediaItemRequestAttrs.setPagingOption(pagingOption);
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("duration");
try {
MediaResponse mediaResponse = mMetadataV2.getAdvancedMetadata().getChildMediaByAggregateMediaUri("mediaL:abc323", requestFields, mediaItemRequestAttrs);
List<MediaItem> mediaItemList = mediaResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaResponse.getPagingResponse();
} catch (Metadata.MetadataException e) {
//Exception
}
In the example above, the media URI of the TV series is provided along with the requested fields in MediaItemRequestAttrs. The pagination settings specify an offset of 11 and a page size of 20, meaning the API response will include items ranging from 11 to 30. The method returns a List<MediaItem>. The method also throws the MetadataException.
8.4. Advanced Metadata Asynchronous call#
public RequestMediaAggregate getChildMediaByAggregateMediaUri(String mediaUri,
Set<String> selectedFields,
MediaItemRequestAttrs mediaAttrs,
Metadata.OnMediaItemListReceivedListener mediaAggregateResponseListener)
- Parameter
- mediaUri - Media data URI, which is returned by #getCategoryMediaByCategoryId(String,String,Set, OnMediaItemListReceivedListener )
- selectedFields - Specifies the fields to return. If null, all fields will be returned.
- mediaAttrs - The parameter configures pagination, passes a list of blocked MIDs to exclude those media items from the callback, and specifies selected fields so the API returns only those fields. It also accepts a seat class parameter to filter and display media items based on class.
- mediaAggregateResponseListener - Metadata.Listener: This callback will be invoked in the context of the calling thread.
- Return Type
- RequestMediaAggregate - The class contains the executeAsync method that needs to be called to get data
Example
MediaItemRequestAttrs mediaItemRequestAttrs = new MediaItemRequestAttrs();
mediaItemRequestAttrs.setPagingOption(new PagingOption(20,20));
Set<String> requestedFields = new HashSet<>();
requestedFields.add("title");
requestedFields.add("shot_title");
requestedFields.add("genre");
RequestMediaAggregate requestMediaAggregate = mMetadataV2.getAdvancedMetadata().getChildMediaByAggregateMediaUri("media:12ddf", requestedFields, mediaItemRequestAttrs, new Metadata.OnAdvancedMediaResponseListReceivedListener() {
@Override
public void onAdvancedMediaResponseListReceived(MediaResponse mediaResponse, Request request) {
List<MediaItem> mediaItemList = mediaResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaResponse.getPagingResponse();
}
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
//Exception during the API call
}
});
requestMediaAggregate.executeAsync();
In the example above, the media URI, requested fields, media request attributes, and OnAdvancedMediaResponseListReceivedListener are provided. The method retrieves a list of child items for the given media URI. It returns a RequestMediaAggregate object, which includes the executeAsync method that must be called to fetch the data.
9. Retrieving Media Metadata#
Developers can retrieve detailed metadata for a specific media item using the following APIs. Each media item is uniquely identified by its Media URI. The metadata response provides various details, including the title, description, genre, rating, and Media URI (which serves as the media identifier). Additionally, it includes available soundtracks and subtitles, image URLs, the number of associated content items, and URIs of related content (such as episodes in a TV series).
9.1. Single Medida Item#
9.1.1. Synchronous call
public MediaItem getMediaMetadataByMediaUri(String mediaUri,
Set<String> selectedFields)
throws Metadata.MetadataException
- Parameter
- mediaUris - Media URI that is returned by
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- Return type
- Returns the MediaItem object
Example
Set<String> requestedFields = new HashSet<>();
requestedFields.add("title");
requestedFields.add("critic_score");
requestedFields.add("images");
try {
MediaItem mediaItem = mMetadataV2.getMediaMetadataByMediaUri("media:abc123",requestedFields);
} catch (Metadata.MetadataException e) {
//exeception during the API call
}
In the example above, the details of a single media item are being retrieved. The media URI is provided, and the requested fields include title, critic score, and images. The method returns a MediaItem object.
9.1.2. Asynchronous call
public RequestMediaMetadata getMediaMetadataByMediaUri(String mediaUri,
Set<String> selectedFields,
Metadata.OnMediaItemReceivedListener onMediaItemReceivedListener)
- Parameter
- mediaUri - A media URI of the media.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- onMediaItemReceivedListener - The Listener provides the data after the successful completion of the API call.
- Return type
- RequestMediaMetadata - The method returns the RequestMediaMetadata object, which contains executeAsync and cancel methods, and needs to call the executeAsync method to get data asynchronously
Example
RequestMediaMetadata requestMediaMetadata = mMetadataV2.getMediaMetadataByMediaUri("media:abc123", null, new Metadata.OnMediaItemReceivedListener() {
@Override
public void onMediaItemReceived(MediaItem mediaItem, Request request) {
//Obtained the mediaItem details
}
@Override
public void onMetadataError(Metadata.Error error) {
//Invoke if any error occur during the API call
}
});
requestMediaMetadata.executeAsync();
In the example above, the media URI of the item is provided, but the requested field is set to null, meaning all available details of the media item will be retrieved. Additionally, an OnMediaItemReceivedListener is registered to handle the response. The method returns a RequestMediaMetadata object, which can be used to execute or cancel the request.
9.2. Multiple Media Items#
9.2.1. Synchronous call
public List<MediaItem> getMediaMetadataByMediaUris(List<String> mediaUris,
Set<String> selectedFields)
throws Metadata.MetadataException
- Parameter
- mediaUris - A list of media URIs for the data that needs to be retrieved.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- Return Type
- MediaResponse - The object provides a List of MediaItem
Set<String> requestedFields = new HashSet<>();
requestedFields.add("title");
requestedFields.add("critic_score");
requestedFields.add("images");
List<String> mediaUriList = new ArrayList<>();
mediaUriList.add("media:abc123");
mediaUriList.add("media:def:345");
try {
List<MediaItem> mediaItemList = mMetadataV2.getMediaMetadataByMediaUris(mediaUriList, requestedFields);
} catch (Metadata.MetadataException e) {
//Error during API call
}
In the example above, a list of media URIs is provided to retrieve details for multiple media items. These items can be either parent entities, such as a TV series or an album, or child entities, such as TV episodes of a series or tracks within an album. Additionally, specific fields are requested to limit the retrieved data to relevant attributes. The method returns a List<MediaItem>, where each MediaItem represents an individual media entity matching the provided URIs and requested fields.
9.2.2. Asynchronous call
public RequestMediaMetadataList getMediaMetadataByMediaUris(List<String> mediaUris,
Set<String> selectedFields,
Metadata.OnMediaItemListReceivedListener mediaMetadataResponseListListener)
- Parameter
- mediaUris - A list of media URIs for the data that needs to be retrieved.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- mediaMetadataResponseListListener - The interface provides a callback method that returns data on success or invokes an error method if the call fails.
- Return type
- RequestMediaMetadataList - An object containing the executeSync and cancel methods. An executeSync method needs to call the get the data.
Example
Set<String> requestedFields = new HashSet<>();
requestedFields.add("title");
requestedFields.add("critic_score");
requestedFields.add("images");
List<String> mediaUriList = new ArrayList<>();
mediaUriList.add("media:abc123");
mediaUriList.add("media:def:345");
RequestMediaMetadataList requestMediaMetadata = mMetadataV2.getMediaMetadataByMediaUris(mediaUriList, requestedFields, new Metadata.OnMediaItemListReceivedListener() {
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
// List of requested media item
}
@Override
public void onMetadataError(Metadata.Error error) {
// Error in any error occured during the API call.
}
});
requestMediaMetadata.executeAsync();
This example is similar to the one in Section 9.2.2, with the addition of an OnMediaItemListReceivedListener to handle the API response. The method returns a RequestMediaMetadataList object, which includes the executeAsync method that must be called to retrieve the data.
9.2.3. Advanced metadata Synchronous call
public MediaResponse getMediaMetadataByMediaUris(List<String> mediaUris,
Set<String> selectedFields,
MediaItemRequestAttrs mediaAttrs)
throws Metadata.MetadataException
- Parameter
- mediaUris - A list of media URIs for the data that needs to be retrieved.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- mediaAttrs - The parameter configures pagination, passes a list of blocked MIDs to exclude those media items from the callback, and specifies selected fields so the API returns only those fields. It also accepts a seat class parameter to filter and display media items based on class.
- mediaAggregateResponseListener - Metadata.Listener: This callback will be invoked in the context of the calling thread.
- Return type
MediaResponse- An object contains a list of MediaItem and pagination information.
Example
Set<String> requestedFields = new HashSet<>();
requestedFields.add("title");
requestedFields.add("critic_score");
requestedFields.add("images");
List<String> mediaUriList = new ArrayList<>();
mediaUriList.add("media:abc123");
mediaUriList.add("media:def:345");
MediaItemRequestAttrs mediaItemRequestAttrs = new MediaItemRequestAttrs();
mediaItemRequestAttrs.setPagingOption(new PagingOption(100, 20));
try {
MediaResponse mediaResponse = mMetadataV2.getAdvancedMetadata().getMediaMetadataByMediaUris(mediaUriList, requestedFields,mediaItemRequestAttrs);
List<MediaItem> mediaItemList = mediaResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaResponse.getPagingResponse();
} catch (Metadata.MetadataException e) {
//Error during API call
}
In the example above, multiple item details are requested with a specific set of fields. Additionally, MediaItemRequestAttrs is provided to enable pagination within the app. The method returns a MediaResponse, which includes a List<MediaItem> and a PaginationResponse containing page information. In this case, records from positions 101 to 120 are requested.
9.2.4. Advanced metadata Asynchronous
public RequestMediaMetadataList getMediaMetadataByMediaUris(List<MediaRequestItem> requestItems,
MediaItemRequestAttrs mediaAttrs,
Metadata.OnAdvancedMediaResponseListReceivedListener onAdvancedMediaResponseListReceivedListener)
- Parameter
- requestItems - List of MediaRequestItems, an object consisting of media URI and parent media URI.
- mediaAttrs - The parameter configures pagination, passes a list of blocked MIDs to exclude those media items from the callback, and specifies selected fields so the API returns only those fields. It also accepts a seat class parameter to filter and display media items based on class.
- mediaAggregateResponseListener - Metadata.Listener: This callback will be invoked in the context of the calling thread.
- onAdvancedMediaResponseListReceivedListener - Listener provides the data after a successful API call.
- Return type
- RequestMediaMetadataList - A class provides an executeAsync and cancel method.
Example
List<MediaRequestItem> mediaRequestItems = new ArrayList<>();
MediaRequestItem item1 = new MediaRequestItem();
item1.setMediaUri("media:abc123");
MediaRequestItem item2 = new MediaRequestItem("media:xsw122","cde1222");
mediaRequestItems.add(item1);
mediaRequestItems.add(item2);
MediaItemRequestAttrs mediaItemRequestAttrs = new MediaItemRequestAttrs();
mediaItemRequestAttrs.setPagingOption(new PagingOption(100, 20));
RequestMediaMetadataList requestMediaMetadataList = mMetadataV2.getAdvancedMetadata().getMediaMetadataByMediaUris(mediaRequestItems, mediaItemRequestAttrs, new Metadata.OnAdvancedMediaResponseListReceivedListener() {
@Override
public void onAdvancedMediaResponseListReceived(MediaResponse mediaResponse, Request request) {
List<MediaItem> mediaItemList= mediaResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaResponse.getPagingResponse();
}
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
// Error during the Api call
}
});
In the example above, a list of MediaRequestItem containing two items is provided, along with MediaItemRequestAttrs for pagination. An OnAdvancedMediaResponseListReceivedListener is included to handle the API response. The method returns a RequestMediaMetadataList object, which offers the executeAsync() method to initiate the API request and a cancel() method to cancel the request if needed.
10. Searching Media#
The Metadata Service offers an efficient search function that enhances usability and accessibility within the entertainment system. Passengers can quickly locate specific movies, TV shows, or music while browsing the in-flight entertainment system. By searching for titles, actors, or directors, they can easily find their favorite content, improving their overall experience. Developers can implement media search functionality using the following APIs.
10.1. Search by Field#
The function performs a search for media by utilizing specified metadata fields, such as the title, genre, director, release year, actor, and soundtrack. These criteria allow users to refine their search to find specific media items that match the provided information.
10.1.1. Synchronous call
public List<MediaItem> searchMediaByField(SearchFieldAttrs fieldAttrs,
Set<String> selectedFields)
throws Metadata.MetadataException
- Parameter
- fieldAttrs - A SearchFieldAttrs object used to set various search criteria such as actor, director, year, title, genre, soundtrack, subtitle, rating, etc.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- Return type
- List<MediaItem> It returns the list of MediaItem
Example
SearchFieldAttrs searchFieldAttrs = new SearchFieldAttrs();
searchFieldAttrs.setRating("120");
searchFieldAttrs.setTitle("abc");
searchFieldAttrs.setGenre("action");
Set<String> selectedField = new HashSet<>();
selectedField.add("title");
selectedField.add("rating");
selectedField.add("actor");
try {
List<MediaItem> mediaItemList = mMetadataV2.searchMediaByField(searchFieldAttrs,selectedField);
} catch (Metadata.MetadataException e) {
throw new RuntimeException(e);
}
In the example above, the search parameters include rating, title, and genre, while the requested fields are specified as title, rating, and actor. The API retrieves and returns all records that match the given search criteria. The method returns a List<MediaItem>, containing media items that fulfill the specified conditions. Since this method is synchronous, it should not be called from the main thread to prevent UI blocking and potential application performance issues.
10.1.2. Asynchronous call
public RequestMediaSearchByField searchMediaByField(SearchFieldAttrs fieldAttrs,
Set<String> selectedFields,
Metadata.OnAdvancedMediaItemListReceivedListener advancedMediaItemListReceivedListener)
- Parameter
- fieldAttrs - A SearchFieldAttrs object used to set various search criteria such as actor, director, year, title, genre, soundtrack, subtitle, rating, etc.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- advancedMediaItemListReceivedListener - Callback provides the data after the successful completion of an API call.
- Return type
- RequestMediaSearchByField - An object of RequestMediaSearchByField provides a method to call API to get data and cancel the request.
Example
SearchFieldAttrs searchFieldAttrs = new SearchFieldAttrs();
searchFieldAttrs.setRating("120");
searchFieldAttrs.setTitle("abc");
searchFieldAttrs.setGenre("action");
Set<String> selectedField = new HashSet<>();
selectedField.add("title");
selectedField.add("rating");
selectedField.add("actor");
RequestMediaSearchByField requestMediaSearchByField = mMetadataV2.searchMediaByField(searchFieldAttrs, selectedField, new Metadata.OnAdvancedMediaItemListReceivedListener() {
@Override
public void onAdvancedMediaItemListReceived(MediaItemsResponse mediaItemsResponse, Request request) {
List<MediaItem> mediaItemList = mediaItemsResponse.getMediaItems();
MediaResponse.PagingResponse pagingResponse = mediaItemsResponse.getPagingResponse();
}
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
//Error during the API Call
}
});
requestMediaSearchByField.executeAsync();
This example is similar to Section 10.1.1, with the key difference being the inclusion of the Metadata.OnAdvancedMediaItemListReceivedListener() listener. This listener handles the API response asynchronously, providing a list of media items and pagination details without blocking the thread. The method returns a RequestMediaSearchByField object, which includes the executeAsync method that must be explicitly called to fetch the data.
10.2. Search by text#
Conducts a search for a specified text string across multiple fields within the dataset. These fields may include attributes such as title, director, actors, and other relevant metadata. This enables users to retrieve results matching the given text in any specified fields, improving search flexibility and relevance.
10.2.1. Synchronous call
public List<MediaItem> searchMediaByText(String searchText,
String seatClass,
MediaType mediaType,
String lang,
boolean exactMatch,
Set<String> selectedFields)
throws Metadata.MetadataException
- Parameter
- searchText - The text that will be searched across the specified fields in the database. The search text is case-insensitive.
- seatClass - Sets the seat class, such as First or Economy, with values defined in
SeatClass. - mediaType - Performs a search based on a specific media type, such as movies, TV shows, or albums. The available values are defined in MediaType. If
nullis provided, the search will include all media types. - lang - Searches using the ISO 639-2 language code. The default language is set to "eng" (English) if not provided.
- extractMatch - a boolean value that specifies whether the search should match the exact word or phrase. If not provided, the default value is
false. - selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- blockedList - A list of MIDs or media URIs to be excluded from the results.
- Return type
- List<MediaItem> - The method returns the list of MediaItem
Example
try {
Set<String> selectedFields = new HashSet<>();
selectedFields.add("title");
selectedFields.add("duration");
List<MediaItem> mediaItems = mMetadataV2.searchMediaByText("tom",SeatClass.ALL,MediaType.MOVIE,"eng",false,selectedFields);
} catch (Metadata.MetadataException e) {
//Exception
}
In the example above, the search text is "tom," the seat class is "all," the content type is "movie," the language is "English," and the exact match is set to false. The request includes the title and duration. The search operation is performed across the title, director, actor, genre, year, and rating fields. The method returns a list of MediaItem objects and may also throw a MetadataException.
10.2.2. Asynchronous call
public RequestMediaSearchByText advancedMediaSearchByText(AdvancedTextSearchAttrs advanceTextSearchAttrs,
Set<String> selectedFields,
Metadata.OnAdvancedMediaItemListReceivedListener advancedMediaItemListReceivedListener)
- Parameter
- advanceTextSearchAttrs- An object is used to set various properties such as searchText, soundtrack language, subtitle language, match type, seat class, pagination option, etc.
- selectedFields - Specifies the fields to return. Values include title, description, and image. If null, all fields will be returned.
- advancedMediaItemListReceivedListener - Responds to the successful completion of the API call.
- Return type
- RequestMediaSearchByText- An object provides methods to either execute or cancel the request.
Example
Set<String> requestFields = new HashSet<>();
requestFields.add("title");
requestFields.add("duration");
AdvancedTextSearchAttrs advancedTextSearchAttrs = new AdvancedTextSearchAttrs();
advancedTextSearchAttrs.setSearchText("tom");
advancedTextSearchAttrs.setMatch(MatchType.BROAD_MATCH);
advancedTextSearchAttrs.setMediaType(MediaType.MOVIE);
advancedTextSearchAttrs.setPagingOption(new PagingOption(0, 20));
RequestMediaSearchByText mediaSearchByText = mMetadataV2.advancedMediaSearchByText(advancedTextSearchAttrs, requestFields, new Metadata.OnAdvancedMediaItemListReceivedListener() {
@Override
public void onAdvancedMediaItemListReceived(MediaItemsResponse mediaItemsResponse, Request request) {
List<MediaItem> mediaItems = mediaItemsResponse.getMediaItems();
//Fuzzy response is obtained only when MatchType.BROAD_MATCH
MediaItemsResponse.FuzzySearchResponse fuzzySearchResponse = mediaItemsResponse.getFuzzySearchResponse();
}
@Override
public void onMediaItemListReceived(List<MediaItem> list, Request request) {
}
@Override
public void onMetadataError(Metadata.Error error) {
}
});
mediaSearchByText.executeAsync();
In the given example, the request is made for two specific fields: title and duration. The search text provided is "tom", and the search is conducted within the movie category. The request specifies a page size of 20 with an offset value of 0, meaning it retrieves the first 20 matching records.
The match type is set to BROAD_MATCH, which allows for flexibility in the search by ignoring minor typos, considering synonyms, and including related variants. The search results are received through the OnAdvancedMediaItemListReceivedListener callback.
The method returns a RequestMediaSearchByText object, which contains the executeAsync() method. This method must be called to initiate the asynchronous retrieval of the search results.
11. How to load Metadata images?#
11.1 Initialization of ImageFetcher service#
The core module includes the Image Fetcher service, which is responsible for retrieving images. In order for the service to function properly, it requires initialization before it can start fetching images. Once initialized, the Image Fetcher service is capable of providing the images as Bitmaps, which are the formats used to display the images in the application.
private ImageFetcher imageFetcher;
ImageFetcher.initService(getApplicationContext(), new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
// The image fetcher initialized successfully
imageFetcher = (ImageFetcher) o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
// Error during initialzation
}
}, mInFlight);
11.2 Fetch the image#
public RequestImage getImageByImageInfo(ImageInfo imageInfo,
onImageReceivedListener onImageReceivedListener)
- Parameter
- imageInfo - The MediaItem object contains the ImageInfo object.
- onImageReceivedListener - The image response is handled through the onImageReceivedListener, which provides two methods: onImageReceived and onImageError.
- Return type
- The method returns the RequestImage
RequestImage requestImage = imageFetcher.getImageByImageInfo(imageInfo, new ImageFetcher.onImageReceivedListener() {
@Override
public void onImageReceived(Bitmap bitmap, RequestImage requestImage) {
// Set the Bitmap to the ImageView
imageView.setImageBitmap(bitmap);
}
@Override
public void onImageError(ImageFetcher.Error error) {
//Error during the image loading
}
});
requestImage.executeAsync();
In the example above, the ImageInfo is provided through the MediaItem object. The response is received via the ImageFetcher.onImageReceivedListener. The onImageReceived method provides a Bitmap, which is then used to set the ImageView.
12. Retrieve Media Kit Information#
The complete media library accessible through the Metadata service is packaged and delivered to the airline operator as a media kit. Using the Metadata service, developers can retrieve key information such as the media kit version and part number, both for ground and in-air modes.
Knowing which media kit version is currently loaded allows the airline to tailor the mobile app experience as per its content strategy. Example use cases include:
-
Delivering a more relevant, seasonal, or personalised passenger experience.
-
Dynamically showcasing or highlighting available content based on the media kit version.
12.1 Synchronous call
- Return type
- MediaKitInfo - An Java object which represent the json object for received media kit information.
try {
MediaKitInfo res = mMetadataV2.getMediaKitInfo();
} catch (MetadataException e) {
// Error during API call
}
In the example above, the method returns a MediaKitInfo object and operates synchronously. Avoid calling this method from the main thread. The method also throws the Metadata exception.
12.2 Asynchronous call
- Parameter
- listener - The media kit info response is handled through the listener, which provide one method:
onMediaKitInfoReceived
- listener - The media kit info response is handled through the listener, which provide one method:
- Return type
- RequestMediaKitInfo - An object which provides methods to either execute or cancel the request.
RequestMediaKitInfo requestMediaKitInfo = mMetadataV2.getMediaKitInfo(new MetadataV1.OnMediaKitInfoReceivedListener() {
@Override
public void onMediaKitInfoReceived(MediaKitInfo mediaKitInfo, Request request) {
// On successful call of method, media kit information is obtained with this mediaKitInfo object.
}
@Override
public void onMetadataError(MetadataV1.Error error) {
// Invoked this when any error trigger during method call
}
});
// Run this method to start the request
requestMediaKitInfo.executeAsync();
In the method above, an OnMediaKitInfoReceivedListener must be provided which returns a mediaKitInfo object. The method returns a RequestMediaKitInfo object, which includes the executeAsync method that must be explicitly called to retrieve the data.
13. Media Trailer Streaming in Ground Mode#
Media trailer streaming allows media content to be streamed directly from a URL hosted on a designated server or within a specific network (referred to as the "Ground server"). The URL serves as a reference to media files accessible via the internet or a local network. This feature is particularly useful for applications that require scalable and efficient streaming of video content from web-based or network resources.
- To implement this feature:
- Check the
MediaItemfor the availability of thestreamingUrlby callinggetCategoryMediaByCategoryId(String categoryID) - If
streamingUrlis available, pass it to the nativeMediaPlayerfor playback
- Check the
MediaPlayer player = new MediaPlayer();
try {
player.setDataSource(this, Uri.parse(streamingUrl));
player.setOnPreparedListener(mp -> {
// Control player behavior once it's prepared
});
player.setOnCompletionListener(mp -> {
// Handle actions after media playback is complete
});
player.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
In the implementation above, the streamingUrl must be provided and must point to a valid media file (e.g., video or audio) hosted on the Ground server. If the streamingUrl is missing, null, or invalid, the MediaPlayer will not have a data source to play, resulting in a blank or non-functional player.
Always validate that streamingUrl exists in the MediaItem before passing it to the MediaPlayer. Add appropriate checks to handle such cases gracefully, such as displaying an error message or fallback behaviour.
Version 1.0