Skip to content

Live TV Implementation for Android PED#

1. Initializing the eXTV Metadata Service#

To fetch the Live TV channel list and handle launching Live TV, initialize the mExtvMetadataV1 service object.

Property Declaration

private ExtvMetadataV1 mExtvMetadataV1;

Initializing mExtvMetadataV1

The ExtvMetadataV1 instance must be initialized using onInitServiceComplete. The onInitServiceFailed will contain an error code if initialization fails.

ExtvMetadataV1.initService(getBaseContext(), new IInFlightCallback() {

    @Override
    public void onInitServiceComplete(Object mServiceObject, String serviceName) {

        Log.v(TAG, "onInitServiceComplete: ");
        mExtvMetadataV1 = (ExtvMetadataV1) mServiceObject;
    }
    @Override
    public void onInitServiceFailed(String serviceName, InFlight.Error error) {
        Log.e(TAG, "onInitServiceFailed: ");
    }
}, inFlight);

Error Codes

  • ExtvMetadataV1.Error: Domain for error handling related to eXTV metadata initialization.

2. Fetching Available Stations#

To retrieve metadata for all available stations, use the getAvailableStations API.

API Description

public void getAvailableStations(ExtvMetadataV1.AvailableStationInfoListener availableStationInfoListener)
  • Parameters:

  • ExtvMetadataV1.AvailableStationInfoListener: This callback function will be called once the available stations request processed successfully. This Interface contains onAvailableStationInfoReceived method and provides the list of available stations info.

Implementation Example

mExtvMetadataV1.getAvailableStations(new ExtvMetadataV1.AvailableStationInfoListener() {
                @Override
                public void onAvailableStationInfoReceived(List<ExtvMetadataV1.StationInfo> stationInfoList) {
                   // The list of available stations info retrieved successfully.

                }

                @Override
                public void onExtvMetadataError(ExtvMetadataV1.Error error) {
                   //If any error occured during the retrival of stationInfoList, this method will get invoked.
                }
            });
        }

ExtvMetadataV1.StationInfo :Each station retrieved is an instance of ExtvMetadataV1.StationInfo, representing a station and providing associated metadata. This class is used when calling the getAvailableStations method of ExtvMetadataV1. It contains properties such as:

stationId The ID of the station
audioLang An array of three-letter language codes used for mapping the title and description of the station into the respective languages.
titles Returns the Title for station based on isoCode provided. If not specified will return the default one.
description Returns the description for station based on isoCode provided. If not specified will return the default one.
callSign The call sign of the station.
mediaUri The identification of the media.
mediaID The MID associated with this station. This will only be populated if the station is not dynamic. Otherwise it will be empty.
isDynamic A flag indicating whether the station is static (predetermined in the media load) or dynamic (enabled mid-cycle).
posterSizeSelectorMap Returns the Synopsis size selector map with keys of image sizes from mediaDb to their poster image URL.
synopsisSizeSelectorMap Returns the Synopsis size selector map with keys of image sizes from mediaDb to their synopsis image URL.
stationType Returns an array containing the constants of this enum type, in the order they are declared.

3. Retrieving Station Status#

To fetch the current status of a specific station, use the getStationStatus API.

API Description

public void getStationStatus(int stationId, ExtvMetadataV1.StationStatusListener stationStatusListener)
  • Parameters:

  • stationID: The ID for the station whose status is requested.

  • ExtvMetadataV1.StationStatusListener: This callback function will be called once the station status request processed successfully, and returns the station status.

Implementation Example

// Calling getStationStatus method from mExtvMetadataV1 object
mExtvMetadataV1.getStationStatus(Integer.parseInt(stationId), new ExtvMetadataV1.StationStatusListener() {
                            @Override
                            public void onStationStatusReceived(Bundle resBundle) {
                            // This callback method is triggered when station status is successfully received
                            }

                            @Override
                            public void onExtvMetadataError(ExtvMetadataV1.Error error) {
                             // This callback method is triggered when there is an error retrieving the station status
                            }
                        });
                    }

4. Launching Live TV#

To launch Live TV in an external browser or an embedded WebView, use the getLiveTvUrl API.

API Description

public String getLiveTvUrl(String hostName, String channelID, boolean showChannel, String backURL)
  • Parameters:

  • hostName: The hostname of the server to which to connect. Contact the Panasonic team to obtain the correct hostname.

  • channelID: A string that specifies which channel to launch in the browser. Use the mediaURI property received from onAvailableStationInfoReceived, obtained through the getAvailableStations API.

  • showChannel: BOOL, if YES it will list the available channels in the browser.

  • backURL: The URL String to redirect to after clicking the back button from the portal. If provided, the user will be taken to this specific page when navigating back.

Implementation Example

// Generating the Live TV URL using getLiveTvUrl() method
String url = mExtvMetadataV1.getLiveTvUrl("livetv.Inflightpanasonic.aero",selectedChannelId, true, "");
             // Creating an Intent to open the generated URL in a web browser
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
              // Starting the activity to open the URL in a web browser
                startActivity(browserIntent);
            }

This method generates a URL that can be used to launch EXTV programs directly in a web browser or in an embedded Webview. To launch Live TV in a WebView, use WebView in Android and use the provided method to load the URL within the WebView. It provides a seamless way to integrate EXTV streaming within the application using browser-based access.

Live TV Implementation

5. Handling Changes in Available Stations#

To get notified about station list updates, use setStationListingChangedListener.

API Description

public void setStationListingChangedListener(ExtvMetadataV1.StationListingChangedListener stationListingChangedListener)

Listener Handling Method

// Setting a listener to detect when the station listing changes
mExtvMetadataV1.setStationListingChangedListener(new ExtvMetadataV1.StationListingChangedListener() {
                @Override
                public void onStationListingChanged() {
              // This event will be triggered when the station listing is updated.
                }
                @Override
                public void onExtvMetadataError(ExtvMetadataV1.Error error) {
               // Handle any error that occurs while fetching station listings
                }
            });

onStationListingChanged : This will give the list of updated stations using ExtvMetadataV1.StationListingChangedListener - this callback function will be invoked when the list of available stations changes.

Conclusion#

This document outlines the steps required to integrate Live TV functionality using ExtvMetadataV1. Developers can use these APIs to retrieve channel lists, check station status, handle errors, and launch Live TV seamlessly within their applications.

Version 1.0