Monitor THEOplayer | Mux

Monitor THEOplayer

Connect Mux Data to the THEOplayer Android SDK to collect playback performance metrics. Use this guide when your Android application plays video with THEOplayer.

In this guide:

Features

The following data can be collected by the Mux Data SDK when you use the THEOplayer Android SDK, as described below.

Supported Features:

Notes:

renditionchange events are tracked, bitrate metrics are not available.

1 Install the Mux Data SDK

Add the Mux SDK to your project using one of the following approaches:

Add Gradle dependency on the Mux THEOplayer SDK (preferred)

Add the Mux Maven repository to your Gradle file:

// Add this

Next, add a dependency on the Mux Data THEOplayer SDK. The latest version of our SDK can be found here.

// Add dependency

2 Initialize the monitor with your THEOplayer instance

Get your ENV_KEY from the Mux environments dashboard.

Env Key is different than your API token

ENV_KEY is a client-side key used for Mux Data monitoring. These are not to be confused with API tokens which are created in the admin settings dashboard and meant to access the Mux API from a trusted server.

First, create the CustomerPlayerData and CustomerVideoData objects as appropriate for your current playback, and be sure to set your ENV_KEY.

// Create CustomerPlayerData and CustomerVideoData

Next, create the MuxStatsSDKTHEOPlayer object by passing your Android Context (typically your Activity), a THEOplayerView instance, a player name, and the customer data objects.

// Create MuxStatsSDKTHEOPlayer

In order to correctly monitor if the player is full-screen, provide the screen size to the MuxStatsSDKTHEOPlayer instance.

// Set screen size

In order to determine a number of viewer context values as well as track the size of the video player, set the player view.

// Set player view

Finally, when you are destroying the player, call the MuxStatsSDKTHEOPlayer.release() function.

// Release MuxStatsSDKTHEOPlayer

After you've integrated, start playing a video in your player. A few minutes after you stop watching, you'll see the results in your Mux data dashboard. Login to the dashboard and find the environment that corresponds to your env_key and look for video views.

3 Add Metadata

In the Java SDK, options are provided via the objects within the CustomerData object.

All metadata details except for envKey are optional; however, you'll be able to compare and see more interesting results as you include more details. This gives you more metrics and metadata about video streaming and allows you to search and filter on important fields like the player version, CDN, and video title.

For more information, see the Metadata Guide.

4 Advanced

Changing the video

There are two cases where the underlying tracking of the video view needs to be reset. First, when you load a new source URL into an existing player, and second, when the program within a singular stream changes (such as a program within a live stream).

Note: You do not need to change the video info when changing to a different source of the same video content (e.g., different resolution or video format).

New source

When you change to a new video (in the same player), you need to update the information that Mux knows about the current video. Examples of when this is needed are:

This is done by calling muxStatsTHEOplayer.videoChange(CustomerVideoData) which will remove all previous video data and reset all metrics for the video view. See Metadata for the list of video details you can provide. You can include any metadata when changing the video but you should only need to update the values that start with video.

It's best to change the video info immediately after telling the player which new source to play.

New program (in single stream)

In some cases, you may have the program change within a stream, and you may want to track each program as a view on its own. An example of this is a live stream that streams multiple programs back to back, with no interruptions.

In this case, call muxStatsTHEOplayer.programChange(CustomerVideoData). This will remove all previous video data and reset all metrics for the video view, creating a new video view. See Metadata for the list of video details you can provide. You can include any metadata when changing the video but you should only need to update the values that start with video.

Detect when a video is being played full-screen

For most use cases, the SDK is capable of detecting whether or not a video is being played full-screen. Specifically, it can do so in the case where the player view is the same size as the device display (excepting ActionBars and other framework window decoration).

For other use cases (non-overlaid controls, window decoration via plain Views, etc.) you may need to tell the SDK when the user switches to full-screen.

Error tracking

By default, Mux's integration with THEOplayer automatically tracks fatal errors as thrown by THEOplayer. If a fatal error happens outside the context of THEOplayer and you want to track it with Mux, you can call muxStatsTHEOplayer.error like this:

// Track error

Note that muxStatsTHEOplayer.error(MuxErrorException e) can be used with or without automatic error tracking. If your application has retry logic that attempts to recover from THEOplayer errors then you may want to disable automatic error tracking like this:

// Disable automatic error tracking

It is important that you only trigger an error when the playback has to be abandoned or aborted in an unexpected manner, as Mux tracks fatal playback errors only.

Release notes

Current release

v0.4.2

Updates:

Previous releases

v0.4.1

Improvements:

v0.4.0

Improvements:

v0.3.0

Improvements:

v0.2.0

Updates:

v0.1.3

Fixes:

v0.1.2

Improvements:

v0.1.1

Track your video engagement and performanceTHEOplayer (iOS) Track your video engagement and performanceFlowplayer