Android PED Recommendation#
The recommendation suggests media content to passengers during a flight by analyzing their profile preferences, previously watched or similar content, and trending media among other passengers. This ensures a personalized and engaging in-flight entertainment experience
1. Initialize Recommendation Service#
The initService method is the entry point for initializing the Recommendation service in the InFlight system. The service object is provided via the IInFlightCallback once initialization is complete.
Recommendation recommendation;
Recommendation.initService(this, new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
//After successful initialization of recommendation, recommendation object provided by the callback
recommendation = (Recommendation) o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
//If any error occured during initilization this method get invoked
}
},new InFlight());
Parameters:
-
context (
Context): The Activity context required to initialize the service. -
inFlightCallback (
IInFlightCallback): Callback that is triggered upon successful service initialization. -
inFlight (
InFlight): Reference to the InFlight object.
2. APIs Available Through the Initialized Recommendation Object#
2.1 API: getSimilarMedia
The getSimilarMedia method retrieves a list of media URIs that are similar to the specified media_uri. This API can be utilized in various scenarios, such as displaying related content on the content synopsis page to help users discover similar media. Additionally, it can be used to present recommendations after a user has finished watching a particular piece of content, enhancing the viewing experience by suggesting relevant options.
By default, the list contains 10 items, sorted in descending order. The results can be filtered by media content, media category, and request limit. Additionally, specific media URIs can be excluded by providing a list of blacklist_uris
recommendation.getSimilarMedia("media.video.movie", mediaUriList, mediaSimilarRequestAttribute, new Recommendation.OnMediaRecommendationReceivedListener() {
@Override
public void onMediaRecommendationReceived(List<RecommendationByCategory> list) {
}
@Override
public void onError(Recommendation.Error error) {
}
});
Method Signature:
public void getSimilarMedia(String contentType,
List<String> mediaURIs,
MediaSimilarRequestAttribute similarMediaAttr,
Recommendation.OnMediaRecommendationReceivedListener onMediaRecommendationReceivedListener)
Parameters:
-
mediaURIs (
List<String>): A list of media URIs used to find similar content. -
contentType (
String): The content type to filter the results, such asmedia.video.movieormedia.audio.album. -
similarMediaAttr (
MediaSimilarRequestAttribute): Optional parameters like category filters and request limits, as detailed below: -
getBlackListedMediaUris: Retrieves the list of URIs that should be excluded from the search results.
- setBlackListedMediaUris: Allows setting a list of URIs to be excluded from the search results.
- getCategories: Retrieves the categories of media to be used in the search for similar content.
- setCategories: Allows setting categories of media to filter the results.
- getSimilarMediaResponseLimit: Retrieves the maximum number of media URIs to return per category (default is 10).
-
setSimilarMediaResponseLimit: Allows setting the maximum number of media URIs to return per category (default is 10).
-
onMediaRecommendationReceivedListener (
Recommendation.OnMediaRecommendationReceivedListener): Listener triggered upon request completion or error.
2.2 API: getRecommendations
The getRecommendations method retrieves a list of similar items based on the passenger's viewing history and playlist. The recommendation obtains this data from the IPS service, which collects and stores historical viewing data based on the passenger's content consumption patterns. The IPS continuously accumulates this data from passenger interactions, allowing the recommender to generate personalized suggestions tailored to the passenger's preferences.
By default, the list includes 10 items, sorted in descending order. The results can be filtered by media content, category, and request limit. Specific media URIs can also be excluded by providing a blacklist_uris list.
recommendation.getRecommendations("media.video.movie", mediaRecommendationRequestAttribute, new Recommendation.OnMediaRecommendationReceivedListener() {
@Override
public void onMediaRecommendationReceived(List<RecommendationByCategory> list) {
}
@Override
public void onError(Recommendation.Error error) {
}
});
Method Signature:
public void getRecommendations(String contentType,
MediaRecommendationRequestAttribute recommendationMediaAttr,
Recommendation.OnMediaRecommendationReceivedListener onMediaRecommendationReceivedListener)
Parameters:
-
contentType (
String): The content type to filter the recommendations, such asmedia.video.movieormedia.audio.album. -
recommendationMediaAttr (
MediaRecommendationRequestAttribute): Optional parameters for additional filtering, including: -
getPairedSeatNumber: Retrieves the seat number of the requesting passenger.
- setPairedSeatNumber: Sets the seat number of the requesting passenger.
- getRecommendedMediaResponseLimit: Retrieves the maximum number of recommended items to return (default is 5).
- setRecommendedMediaResponseLimit: Sets the maximum number of recommended items to return.
- getBlackListedMediaUris: Retrieves the URIs of media to be filtered out from the recommendations.
- setBlackListedMediaUris: Allows setting a list of media URIs to be excluded from the recommendations.
- getCategories: Retrieves categories of media for finding similar content.
-
setCategories: Allows setting categories of media for filtering the recommendations.
-
onMediaRecommendationReceivedListener (
Recommendation.OnMediaRecommendationReceivedListener): Listener triggered upon completion or in case of error during the request.
2.3 API: getTrendingMedia
The getTrendingMedia method returns a list of media URIs that are currently or recently watched by passengers on the flight. The list is based on the number of passengers viewing the media and defaults to 10 items in descending order. Results can be filtered by content type, media category, and request limits, with the option to exclude certain media URIs using a blacklist.
recommendation.getTrendingMedia("media.video.movie",
mediaTrendingRequestAttribute, new Recommendation.OnMediaRecommendationReceivedListener() {
@Override
public void onMediaRecommendationReceived(List<RecommendationByCategory> list) {
}
@Override
public void onError(Recommendation.Error error) {
}
});
Method Signature:
public void getTrendingMedia(String contentType,
MediaTrendingRequestAttribute trendingMediaAttr,
Recommendation.OnMediaRecommendationReceivedListener onMediaRecommendationReceivedListener)
Parameters:
-
contentType (
String): The content type to filter the trending media results, such asmedia.video.movieormedia.audio.album. -
trendingMediaAttr (
MediaTrendingRequestAttribute): Additional optional filtering parameters, including: -
getPairedSeatNumber: Retrieves the seat number of the requesting passenger.
- setPairedSeatNumber: Sets the seat number of the requesting passenger.
- getBlackListedMediaUris: Retrieves URIs of media to be excluded from the trending media results.
- setBlackListedMediaUris: Allows setting a list of media URIs to be filtered out.
- getCategories: Retrieves the categories of media to be used for filtering trending content.
- setCategories: Allows setting categories of media for filtering trending results.
- getTrendingMediaItemLimit: Retrieves the maximum number of trending media items to return (default is 10).
-
setTrendingMediaItemLimit: Allows setting the maximum number of trending media items to return (default is 5).
-
onMediaRecommendationReceivedListener (
Recommendation.OnMediaRecommendationReceivedListener): Listener triggered upon request completion or in case of an error.
2.4 API: getEnsembleMedia
The getEnsembleMedia method works the same as calling getRecommendations, getTrendingMedia, and getPopular simultaneously.
Since there is no dedicated method for fetching popular recommendations, this method must be used to obtain a list of popular items. It retrieves items based on box office revenue data from the ROVI dataset, making it suitable for initial recommendations when a flight opens or immediately after an interactive session starts, particularly when history or usage data is unavailable. Alternatively, it may be a predefined, curated list from the ground.
Not only does it reduce multiple network requests, but it also prevents duplicate items from appearing across various lists. For instance, an item that is both recommended and trending will only be included once, ensuring a more diverse and streamlined set of results.
By default, the API returns 15 items, including 5 recommendations, 5 popular items, and 5 trending items. The results can be customized by applying filters based on media content type, category, and a specified request limit. Additionally, specific media URIs can be excluded from the response by providing a blacklist_uris list, ensuring that certain content is omitted from the returned results.
recommendation.getEnsembleMedia("media.video.movie",
mediaEnsembleRequestAttribute, new Recommendation.OnMediaRecommendationReceivedListener() {
@Override
public void onMediaRecommendationReceived(List<RecommendationByCategory> list) {
}
@Override
public void onError(Recommendation.Error error) {
}
});
Method Signature:
public void getEnsembleMedia(String contentType,
MediaEnsembleRequestAttribute ensembleMediaAttr,
Recommendation.OnMediaRecommendationReceivedListener onMediaRecommendationReceivedListener)
Parameters:
-
contentType (
String): The content type to filter the ensemble media results, such asmedia.video.movieormedia.audio.album. -
ensembleMediaAttr (
MediaEnsembleRequestAttribute): Contains additional parameters, including: -
getRecommendedMediaResponseLimit: Gets the limit of recommended items to return (default is 5).
- setRecommendedLimit: Sets the maximum number of recommended items to return (default is 5).
- getPopularMediaResponseLimit: Gets the limit of popular items to return (default is 5).
- setPopularLimit: Sets the maximum number of popular items to return (default is 5).
- getPairedSeatNumber: Retrieves the seat number of the requesting passenger.
- setPairedSeatNumber: Sets the seat number of the requesting passenger.
- getBlackListedMediaUris: Retrieves URIs of media to be excluded from the ensemble media results.
- setBlackListedMediaUris: Sets a list of media URIs to be filtered out.
- getCategories: Retrieves categories of media to be used for filtering.
-
setCategories: Allows setting categories of media for filtering results.
-
onMediaRecommendationReceivedListener (
Recommendation.OnMediaRecommendationReceivedListener): Listener that will be executed upon request completion or in case of an error.
2.5 API : getGenres
Retrieves and provides a comprehensive list of genres associated with a particular type of content. Each genre in the list is mapped to its corresponding translated name based on the specified ISO 639 language code, ensuring that the genres are presented in the appropriate localized format.
These genres can be stored in the user's profile preferences. Based on these preferences, relevant recommendations can be generated.
recommendation.getGenre("media.video.movie", "eng", new OnGenreReceivedListener() {
@Override
public void onGenreReceived(List<String> genreList) {
//List of genre will be obtain after succesful completion of API call
}
@Override
public void onError(Error error) {
//Invoke this method if any error during fetching the genre list
}
});
Method Signature:
Parameters:
-
contentType - The content type for which genres are to be retrieved.
-
langIso - The ISO language code specifies the translation to be used.
-
genreReceivedListener - The listener used to obtain the list of genres list,
2.6 API: cancel
The cancel method cancels all pending or ongoing media recommendation requests made using the initialized Recommendation object. This ensures that no further results or callbacks will be triggered from the canceled requests.
Method Signature:
3. Listeners#
3.1 The recommendation response listener
The Recommendation API includes a listener that is responsible for receiving and processing responses from the recommendation service. This listener acts as a unified component that handles responses for all types of recommendation API requests.
private OnMediaRecommendationReceivedListener onMediaRecommendationReceivedListener = new OnMediaRecommendationReceivedListener() {
@Override
public void onMediaRecommendationReceived(List<RecommendationByCategory> recommendationByCategories) {
//After successfully retrieving data from the recommendation service, this method is get invoked and providing the data
//recommendationByCategories is list contains the recommendation data, It may contians data of multiple categories
for(RecommendationByCategory recommendationByCategory : recommendationByCategories) {
//Single category item
List<RecommendationType> recommendationTypeList = recommendationByCategory.getRecommendationType();
//For single category item it contains multiple recommendation
//For e.g. in case getEnsemble API list of trending, popular, recommendations list is obtained.
//In case of other API only one list obtained in the response
for (RecommendationType recommendationType : recommendationTypeList) {
List<MediaRecommendation> mediaRecommendationList = recommendationType.getMediaRecommendations();
MediaRecommendationType type = recommendationType.getRecommendationType();
}
}
}
@Override
public void onError(Error error) {
//Any error occured during API call, this method get invovked
}
};
The given code snippet illustrates that the recommendation response is obtained through the onMediaRecommendationReceived method. This method provides a list of RecommendationByCategory objects, as the recommendation API allows retrieving data for multiple categories. As a result, the response is organized in a category-wise format, ensuring that media recommendations are grouped based on their respective categories.
Each RecommendationByCategory object contains a list of RecommendationType objects. Each RecommendationType represents a specific category of recommendations, such as trending, popular, similar, or recommended suggestions. Additionally, the RecommendationType object includes a list of MediaRecommendation objects, which store detailed information about the recommended media content within that specific recommendation type.
Version 1.0