Skip to main content
Skip table of contents

Insight analytics

The application can report player metrics to the Insight servers using the Insight Agent class.

The application uses the Agent to manage playback sessions, during which content information and playback monitoring information are collated. A session lifecycle normally equates with the playback of one content, starting at the moment the content is loaded into the player and ending when the content is unloaded from the player.

The application is responsible for:

  • Instantiating and driving the player
  • Providing some metadata about the content

The Agent is responsible for:

  • Observing metrics and events on the player
  • Reporting metrics and events to the Insight servers

Prerequisites

You must have the NAGRA Insight pay-TV intelligence platform.

Example code

The Insight Agent needs the analytics.json configuration file, which is read on object creation. The analytics.json configuration file is located at: res/raw/analytics.json

Before the application can instantiate the Agent, you must define the following parameters in the configuration file:

ParameterDescription
InsightCollectorURLThe base URL for the Insight server collecting the metrics
reportingPeriodInitialDelayThe delay (ms) before the agent starts sending the report
reportingPeriodThe interval between regular reports (ms)


Create the agent

To create an Agent, the application provides the application context to the Agent:

JAVA
mInsightAgent = new Agent(mContext);

The same Agent can be reused for multiple playback sessions, so there's usually no need to instantiate this class more than once.

Start a session

A session must be configured with two things:

  • A player to listen to
  • Information about the content that is being played

The content information object is used to pass metadata from the application to the Insight Agent, for use in playback metrics and events reporting. The application starts a session on the agent using both the ContentInfoHolder and NMPVideoView objects:

JAVA
mInsightAgent.startSession(mNmpVideoView, contentInfoHolder);
ClassDescription
ContentInfoHolderThis class contains the representation of the metadata for a single content item, including, but not restricted to, its name, genre, duration, and a unique identifier (ContentId)
NMPVideoViewThis class controls the playback of audio/video files and streams served from the assets server

Stop a session

The following method is used to stop the session:

JAVA
mInsightAgent.stopSession();

Update content information

At times, the application might need to update content information when on a live channel. Such updates commonly involve event transitions, where the application provides a new event name or event ID. To update content information, the application needs to stop the session and start a new session on the same player, which includes the new content information. The easiest way to make a change is to update the existing ContentInfoHolder rather than create a new one.

The following code shows how a change in content is implemented:

JAVA
mInsightAgent.stopSession();
contentInfoHolder.setEventName(eventName);
contentInfoHolder.setEventId(eventId);
mInsightAgent.startSession(mNmpVideoView, contentInfoHolder);

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.