Conviva Android Sensor Integration

Explains how to install and integrate the Conviva sensor in Android apps to collect video streaming experience data.

Updated 2026-08-03 android, stream, sensor, sensor developer center, sensor integration
This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK below. Please note that the legacy SDK is deprecated and is not supported from version 4.0.18 and above. To migrate from the legacy SDK to the new SDK, refer to the migration API mapping document here and a summary of the migration benefits here.

Conviva DPI Sensor Integration

Conviva DPI Sensor Installation and Integration

Low-code integration of Conviva DPI sensor enables automatic, and semantic-less data collection.

Integration Methods

  • AI-Assisted Integration: Use a prompt to instruct your AI coding assistants, such as Cursor, Claude Code, OpenAI Codex, ChatGPT, Gemini CLI, GitHub Copilot, Android Studio AI, and any other agent to automatically integrate Conviva Android SDK, without requiring human guidance beyond initial inputs.
Instruct the AI coding assistant to follow the prompts sequentially. Ensure each step is fully completed before proceeding to the next.
Prompt for Conviva Android SDK Integration
Integrate the Conviva Android DPI SDK into this Android project. Follow these steps STRICTLY IN ORDER. 
Do NOT proceed to the next step until the current one is complete.
**Step 1 — Fetch instructions (do this FIRST, before opening any project file):** 
https://github.com/Conviva/conviva-android-appanalytics

**Step 2 — Parse the instructions:** 
Read the fetched README carefully. Extract the complete list of integration steps required. 

**Step 3 — Apply the changes:** For each integration step from the README, 
read or search only the project files that are directly needed to carry out that specific step. 
Do not explore the project speculatively or read files unrelated to the current integration step.

For more details, see:

For installation, add Gradle Dependency and Download the SDK. Follow the README file integration instructions.

The following values are set on the player initialization. Any time these values are cleared during application handling, such viewer logout/logins and background/foreground changes, Conviva recommends storing these values in persistent memory. If these identifiers are not kept persistence, the unique devices and active devices/users values may be inflated: *sharedpreferences/conviva.xml* and *cache/conviva-cache/remoteConfig.data*.

Conviva VSI Sensor Integration

Quick Integration

The quick integration page for Android contains the code snippets that you'll need at various stages of stream sensor integration and serves as a quick reference.

Follow these instructions to complete the Conviva VSI Sensor integration on Android players:

Step 1: Install Conviva Library

  • Install the Conviva library and add dependencies.

  • Initialize the main Conviva objects.

  • Use the Conviva sensor for custom integrations.

Developer Steps

  • Install the Conviva library and add dependencies.

  • Initialize the ConvivaAnalytics object using your CUSTOMER_KEY.

  • Create an instance of ConvivaVideoAnalytics as a videoAnalytics object to report video related events.

  • Create an instance of ConvivaAdAnalytics as an adAnalytics object to report ad related events.

Step 2: Configure Metadata

  • Most metadata is autocollected.

  • Configure additional custom metadata tags (if applicable).

Developers Steps

  • Use the pre-defined metadata key/value pairs.

  • Optionally, set custom metadata.

Step 3: Report Events and Metadata

  • Use Conviva methods to report video stream events and metadata. Conviva computes stream data and metrics.

Developer Steps

  • Implement the videoAnalytics.reportPlaybackRequested(contentInfo) method to report playback attempt requests along with metadata (content, workflow, audience, and other relevant metadata). Populate the contentInfo object with the video stream data.

  • Pass ad loader instance to Conviva by calling adAnalytics.setAdListener (adsLoader, settingsInfo);

  • Use the videoAnalytics.reportPlaybackEnded() method to report end of playback.

Step 4: Integrate Video Players

  • Use Conviva methods to integrate supported or custom video players.

  • Use Conviva methods to integrate supported or custom ad managers.

Developer Steps

  • Integrate any video player with the same programming language it is written in.

  • Use plug-in modules for the most commonly used video players to auto-detect events or use the ConvivaVideoAnalytics class methods to report events from your custom video player.

  • Integrate any ad SDK using the programming language it is written in.

  • Use plug-in modules for the most commonly used ad SDKs to auto-detect events or use the adAnalytics class methods to report events from your custom ad manager.

Step 5: Handle User Actions

Use Conviva methods to handle user actions, such as backgrounding and user events.

Use Conviva methods to report custom events.

Use Conviva methods to control data collection and delete collected data.

Developer Steps

  • Implement the ConvivaAnalytics.reportAppBackgrounded(); for background events.

  • Implement the ConvivaAnalytics.reportAppForegrounded(); for foreground events.

  • Report video related events and application-level events.

  • Manage Data Collection and User Preferences.

Step 6: Clean Up Session

  • Use Conviva release methods to clean up objects on player application exit.

Developer Steps

  • When video playback ends, implement videoAnalytics.reportPlaybackEnded();.

  • When ad content ends, implement adAnalytics.reportAdEnded();.

  • On application exit, implement adAnalytics.release();, videoAnalytics.release();, ConvivaAnalytics.release();.

For advanced users, Conviva provides an integration assistant plugin to help automate the stream sensor integration with Android players. Use the plugin for faster integration with Gradle dependency syncs and a Java Helper class. For more details, see Install and Integrate Using Conviva Library Plugin.

Prerequisites

  • Obtain your account's CUSTOMER_KEYs.**Conviva provides a test account and a production account for Test and Production environments, respectively. You can find your CUSTOMER_KEY here: Pulse - Account Info. Ask your Conviva representative for assistance if you have problems accessing it.

  • Pass the gatewayUrl parameter to init() method of Conviva SDK. The gatewayUrl is specific for your account and shall ONLY be used for tests, never for production deployment.

    Sample gatewayUrl for Testing:

    https://<*customer_key*>.ts-testonly.conviva.com

    IMPORTANT: If there's any doubt on how to set the gateway URL, consult your Conviva representative - this is a critical parameter. For production, Conviva library uses the automatically-assigned gatewayUrl.

    Use Touchstone 2.0 in Pulse to perform self-validation and debugging of video sensor integration

  • For Conviva JavaScript Sensor Integration, you can use any custom gateway URL with a proxy service setup. This is applicable for JavaScript version 4.7.13 onwards.

  • Plan your metadata

    Conviva supports Pre-defined, Device, and Custom metadata. Work with your project team to determine the need to collect any custom metadata. It's also recommended to work with your Conviva representative to create your metadata plan prior to integration.

  • Integration Summary

    Click an image to view the API call sequence:**

    Android Custom Integration (SDK Only)

    Conviva Android Player Modules

    Use for video players other than Brightcove, ExoPlayer, or NexStreaming. Report all the playback metrics, such as bitrate, player states, seek, buffering, and user actions.

    For API call details, refer to Android Custom Integration API List.

    Use for Brightcove, ExoPlayer, and NexStreaming video players. Modules autocollect most playback metrics, such as bitrate, player states, seek, and buffering.

    For API call details, refer to Android Module Integration API List.

    Integration Summary Steps

    1. Install Conviva Library
    • Install the library and add dependencies.

    • Initialize the ConvivaAnalytics object using your CUSTOMER_KEY.

    • Create an instance of ConvivaVideoAnalytics as a videoAnalytics object to report video related events.

    • If your player has ads: Create an instance of ConvivaAdAnalytics as a adAnalytics object to report ad related events.

    1. Configure Metadata
    • Implement the metadata by following the instructions to use the pre-defined keys, as well as custom metadata, if applicable.

    • Implement device metadata (optional). By default, Conviva sensor autocollects Android device metadata.

    1. Report Events and Metadata

    Implement the videoAnalytics.reportPlaybackRequested(contentInfo) method to report playback attempt request along with metadata (content, workflow, audience, and other relevant metadata). Use the videoAnalytics.reportPlaybackEnded() method to report the of end playback.

    1. Integrate Video Players Add Conviva module dependency for your video player (if available), and pass player instance to Conviva by calling videoAnalytics.setPlayer(playerInstance). If following custom integration guidelines, implement video events & metric reporting as prescribed by the corresponding specification. Add Conviva module dependency for your ad player (if available), and pass ad loader instance to Conviva by calling adAnalytics.setAdListener (adsLoader, settingsInfo);. If following custom integration guidelines, implement ad metadata, events & metric reporting as prescribed by the corresponding specification.

    2. Handle User Actions

    • Implement the ConvivaAnalytics.reportAppBackgrounded() / ConvivaAnalytics.reportAppForegrounded() methods to report background events.

    • Implement videoAnalytics.reportPlaybackEvent() method to report user events (user actions, user dialogue, etc).

    • Set the permissions to enable the collection of Network Metrics, manage Data Collection and User Preferences.

    1. Clean Up

    Call 'release' methods to cleanup ConvivaAnalytics, videoAnalytics, adAnalytics objects upon application exit.

    Test and Validate

    1. After integration, perform a sanity check following the test cases in the Stream Sensor Sanity Test Plans spreadsheet. For the full validation test, use the test cases in the Stream Sensor Full Test Plans spreadsheet.

    2. Use Touchstone in Pulse to perform self-validation and debugging of video sensor integration.

    Be sure to replace your TEST CUSTOMER_KEY with the PRODUCTION key to go live with your application, and generate the session traffic to the following Touchstone gateway URL:https://.ts-testonly.conviva.com
    1. Done! Analyse your data in Pulse and improve your viewer experience - let's make video experience better!

    Sample Application

    The sample application illustrating Conviva integration example for ExoPlayer can be found here.

    1. Install Conviva Library

    Conviva provides a library plugin to help automate library installation and sensor integration with Android players. Alternatively, you can install the libraries manually and follow the step-by-step integration process.

    Install and Integrate Using Conviva Library Plugin

    Conviva provides an integration assistant plugin to help automate the stream sensor integration with Android players. Use the plugin for faster integration with Gradle dependency syncs and a generated Java Helper class.

    Install Conviva Library Using Plugin

    These steps help you install the plugin and integrate the Android players.

    Downloading and Installing the Plugin

    1. Download the plugin, ConvivaPlugin-SNAPSHOT.zip.

    2. Open Android Studio on your computer.

    Ensure that you've installed the Android Studio of version Arctic Fox | 2020.3.1 or above.

    *1. To install the plugin, close all the files on Android studio, and drop the zip file from the downloaded folder to the file area in the Android Studio. You can also open the file from Files->Preferences/Settings->Plugin->Install Plugin from Disk...

    *1. Click Restart when the studio prompts for a restart.

    *1. The plugin gets installed with this restart. Click Conviva_ Integration Assistant_ to see it in the studio sidebar. You can also add the plugin to the sidebar from Tools menu.

    *

    1. Choose the SDK to integrate. The plugin supports Core SDK, ExoPlayer, BrightCove, NexPlayer, and IMA modules.
    1. To install the Core SDK library, click _Integrate the_ConvivaCore SDK and choose the SDK version. If you choose the ExoPlayer SDK , then the click Integrate the ExoPlayer SDK. This action starts the Gradle sync to add dependencies to your project.

    *

    1. Click Generate Helper Class and enter values for test and production customer keys, and validation URL. Choose a directory (usually, your project package) to save the helper class file. For example:
    com.mypackage.MyExample.java
    com.mypackage.ConvivaHelper.java
    

    *1. This generates ConvivaHelper.java file with all the code snippets required for integration.

    1. Invoke the helper class methods from your package. For example:
    ConvivaHelper convivaHelper = new ConvivaHelper();
    
    //Builds and returns the ConvivaVideoAnalytics object.
    convivaHelper.buildVideoAnalytics();
    
    //Builds and returns the ConvivaAdAnalytics object.
    convivaHelper.buildAdAnalytics();
    
    1. Advanced Use Cases are also available on the plugin for your reference.

    *1. The integration is complete. Perform self-validation of video sensor integration using Touchstone in Pulse.

    If not using the plugin, you can also install the libraries manually and follow the step-by-step integration process.

    Add Conviva Libraries and Configure Dependencies

    Add jcenter() repository in your root file to automatically install Conviva dependencies via Gradle.

    Add core SDK

    implementation 'com.conviva.sdk:conviva-core-sdk:<version>'
    

    Or download and add the library explicitly from Conviva GitHub: https://github.com/Conviva/conviva-android-coresdk

    Add dependencies

    If using one of the players Conviva provides a module for, add the corresponding dependency as well.

    implementation 'com.conviva.sdk:conviva-exoplayer-sdk:<version>'
    
    implementation 'com.conviva.sdk:conviva-nexplayer-sdk:<version>'
    
    implementation 'com.conviva.sdk:conviva-brightcove-sdk:<version>'
    
    If you are using shrinkResources or minifyEnabled properties in the application to optimize the size of the APK file, then add the following in ProGuard rules:-keep class com.conviva.playerinterface. { *; } -keep, allowshrinking class com.conviva. { *; } -dontwarn com.google.android.exoplayer2.ExoPlayer., * -dontwarn androidx.media3., *

    Add dependencies for Ad SDKs

    Refer to Integrate Ad Managers for the details of ad manager integration.

    implementation 'com.conviva.sdk:conviva-ima-sdk:<version>'
    

    Or download and add the library explicitly from Conviva GitHub: https://github.com/Conviva/conviva-android-imasdk.

    Initialize the top level object

    ConvivaAnalytics.init(Context appContext, String customerKey, Map<String, Object> settings)
    
    • appContext: Android application context;

    • customerKey: String to identify specific customer account. Different keys shall be used for development / debug versus production environment. Find your keys on the account info page in Pulse;

    • settings: Map of Conviva settings to enable debug. Shall NOT be set in production - skip this parameter. No need to set gatewayUrl and LogLevel settings for your production release explicitly. The Conviva sensor has the right default value.

    The allowed parameters are:

    • ConvivaSdkConstants.GATEWAY_URL once enabled, the data will appear in Pulse for performing self-validation of video sensor integration. For more information, see Self-validation using Touchstone.
    • ConvivaSdkConstants.LOG_LEVEL set to ConvivaSdkConstants.LogLevel.DEBUG for debug-level log verbosity.

    IMPORTANT: No need to set GATEWAY_URL and LOG_LEVEL settings for your production release. The Conviva sensor provides the default values for production.

    if(BuildConfig.DEBUG) {
    Map<String, Object> settings = new HashMap<>();
    String gatewayUrl = "YOUR Touchstone Service URL";
    settings.put(ConvivaSdkConstants.GATEWAY_URL, gatewayUrl);
    settings.put(ConvivaSdkConstants.LOG_LEVEL, ConvivaSdkConstants.LogLevel.DEBUG);
    ConvivaAnalytics.init (getApplicationContext(), TEST_CUSTOMER_KEY, settings);
    }else{
    //production release
    ConvivaAnalytics.init (getApplicationContext(), PRODUCTION_CUSTOMER_KEY);
    }
    

    Expected Errors Due to Dual Stack IPv4/v6 Network Support

    When the Conviva sensor is initialized with production settings, the SDK sends a single request to the endpoints below:

    • [customer_key].ipv4.cws.conviva.com for IPv4 only

    • [customer_key].ipv6.cws.conviva.com for IPv6 only

    Sending both requests enables correlation of IPv4 and IPv6 addresses in dual-stack networks. If only IPv4 or IPv6 addressing is used (single-stack networking), it is expected that one request will fail. All the following requests will be sent to the endpoint below which supports both IPv4 and IPv6:

    • [customer_key].cws.conviva.com

    Initialize the video object

    Create instance of ConvivaVideoAnalytics object.

    This object will be used throughout the entire application lifecycle to report video related events.

    ConvivaVideoAnalytics videoAnalytics = 
    ConvivaAnalytics.buildVideoAnalytics(getApplicationContext());
    

    Initialize the ad object

    Only if your application has ads, create ConvivaAdAnalytics object.

    This object will be used throughout the entire application life cycle to report ad related events.

    ConvivaAdAnalytics adAnalytics = ConvivaAnalytics.buildAdAnalytics(getApplicationContext(),videoAnalytics);
    

    This method requires videoAnalytics object created at the previous step passed as a parameter.

    2. Configure Metadata

    Metadata enables analysis of your data using different dimensions, for example, content, audience, device, workflow, player, and operating system.

    Conviva categorizes metadata tags into three buckets (Predefined, Device, Custom).

    Pre-defined Video and Content Metadata

    Conviva defines the constants or fixed string keys for commonly used metadata. These metadata keys provide critical information about video, content, ad content, versioning, and workflow.

    The table below provides the pre-defined metadata fields.

    IMPORTANT: Conviva modules for video players only capable of autocollecting FRAMEWORK_VERSION and FRAMEWORK_NAME. The rest of the metadata shall be set by your application.

    The constants below are defined in the class com.conviva.sdk.ConvivaSdkConstants.

    IMPORTANT: To assign content category labels, such as Audio, Trailer, Tile Play, or Short Video, use the c3.cm.categoryType pre-defined content metadata constant.

    Constants for Pre-defined Video and Content Metadata

    Key Type Implementation Note
    ConvivaSdkConstants.ASSET_NAME string Use unique name for each stream/video asset. Values are up to your choice, but a human-readable text prefixed with the unique video ID works best in most Conviva sensors.
    This provides for clarity in reports and makes most popular content easily identifiable.Pattern: [videoID] Video Title


    The following are typical patterns for VOD (movies and episodic content) and Live streams:
    Movie Pattern: [{contentId}] {Movie Title}
    Sample Value: [12345] The ABC Movie
    Episode Pattern: [{contentId}] {Show Title} - S:{Season Number}:E{Episode Number} - {Episode Title}
    Sample Value: [67890] The XYZ Show - S3:E1 - The Pilot Episode
    Live Stream Pattern: [{channelNumber}] {Chanel Name}
    Sample Value: [10] PQRS Bay Area

    ConvivaSdkConstants.IS_LIVE boolean Denotes whether the content is video on-demand or a live stream. Affects the computation and availability of the Conviva metrics.

    boolean true/false
    ConvivaSdkConstants.ALLOW_BACKGROUND_PLAYBACK boolean

    Tracks metrics even when the application goes to background if the value is set to true. By default, tracking is stopped when the application goes to background.

    boolean true/false

    For audio streaming applications that support playback in the background, you should set this property to true, for collecting accurate metrics.

    Send this to Conviva using the setContentInfo method at the beginning of playback. If needed, you can change it during the playback to adjust its behavior.

    Map<String, Object> contentInfo = new HashMap<>();
    contentInfo.put(ConvivaSdkConstants.ALLOW_BACKGROUND_PLAYBACK, true);
    videoAnalytics.setContentInfo(contentInfo);
    
    ConvivaSdkConstants.PLAYER_NAME string A string value used to distinguish video players (applications). Simple values that are unique across all of your integrated platforms work best here. If the same player used across multiple platforms, e.g., Tizen, LG TV, WEB, give separate names for each application / platofrm: for example, "JS Tizen", "JS LGTV", "JS WEB". Do not include the build or version number in this property. The intention is to have a simple way of differentiating data from different players / platforms.
    ConvivaSdkConstants.VIEWER_ID string Required for Viewers Module. A unique identifier to distinguish individual viewers or devices through Conviva's Viewers Module. The value shall be unique abstract user's identifier. If user is anonymous, do not set any value for this tag.
    ConvivaSdkConstants.STREAM_URL string

    The manifest URL of the video stream. The Conviva backend config server attempts to map a portion of StreamURL into a CDN name. For example: In the URL https://www.akamai.net/avengers.m3u8, akamai.net maps to the AKAMAI label. Conviva VSI users can then retrieve metrics based on the mapped CDN name (AKAMAI, in this case).

    The URL values reported in the streamURL are case insensitive. The streamURLs with either uppercase or all lowercase are acceptable.
    ConvivaSdkConstants.DEFAULT_RESOURCE string

    This value specifies the video server or CDN name from where the streaming resource is played. Set this field when the video server resource cannot be inferred from the STREAM_URL.

    For example, if the streamURL is https://cbd12348.cdn.cms.somewebsitehostname.com/abc.txt, it is not possible to infer the AKAMAI name from the streamURL, and in such a case, it is necessary to report the DEFAULT_Resource as AKAMAI.

    The DEFAULT_Resource value is case sensitive. If the resource name is initially reported as AKAMAI (uppercase) and subsequently modified in the app to akamai (lowercase), it is necessary to inform Conviva about the change because both need to be mapped in the Conviva backend configuration server to ensure that both point to the same CDN name (AKAMAI).
    ConvivaSdkConstants.DURATION integer Duration of the video content, in seconds.
    ConvivaSdkConstants.ENCODED_FRAMERATE integer Encoded frame rate of the video stream in frames per second.
    ConvivaSdkConstants.FRAMEWORK_NAME string

    Video Player Framework Name.

    Autocollected if Conviva module used for video player integration, required for custom integration.

    Otherwise, set using the API videoAnalytics.setPlayerInfo(Map playerInfo):
    Map<String, Object> playerInfo = new HashMap<>();
    playerInfo.put(ConvivaSdkConstants.FRAMEWORK_NAME, "YOUR_FRAMEWORK_NAME");
    videoAnalytics.setPlayerInfo(playerInfo);
    
    ConvivaSdkConstants.FRAMEWORK_VERSION string

    Video Player Framework Version.

    Autocollected if Conviva module used for video player integration, required for custom integration.

    Otherwise, set using the API videoAnalytics.setPlayerInfo(Map playerInfo):
    Map<String, Object> playerInfo = new HashMap<>();
    playerInfo.put(ConvivaSdkConstants.FRAMEWORK_VERSION, "1.2.3");
    videoAnalytics.setPlayerInfo(playerInfo);
    
    "c3.app.version" string Application build version. Shall have the same value for both ads and video.
    "c3.cm.contentType" string Advanced content delivery methods along with Live and VOD.


    Acceptable values: "Live", "Live-Linear", "DVR", "Catchup", "VOD".

    "c3.cm.channel" string The channel on which the content is consumed.


    Example: "ABC".

    "c3.cm.brand" string The name of the brand to which the content belongs.


    Examples: "ABC X", "ABC Y".

    "c3.cm.affiliate" string Affiliate or MVPD name for TV Everywhere authenticated services.


    Examples: "Xfinity", "Comcast".

    "c3.cm.categoryType" string

    Content business categories of interest.

    Use this constant to assign content category labels, such as Audio, Trailer, Tile Play, or Short Video.

    Examples: "Episodic", "Movies", "News", "Sports", "Events", "Informercials", "Shorts", "Promos", "Audio", "Tile Play", "Short Videos", "Trailer".

    "c3.cm.name" string Name of CMS Provider.


    Examples: "CMS", "ROVI", "TMS".

    "c3.cm.id" string Unique asset identifier to query CMS system to gather additional asset metadata information for a specific asset.


    Example: "003b094d-fc5c-3d5a-8ed0-301bf848291e".

    "c3.cm.seriesName" string The name of Series. Set the value only if the metadata cannot be gathered from CMS System. Null if not applicable.


    Examples: "Friends", "Null".

    "c3.cm.seasonNumber" string The Season number. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.


    Examples: "1", "Null".

    "c3.cm.showTitle" string The name of the Episode or Show Title. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.


    Examples: "The One with All the Cheesecakes", "Null".

    "c3.cm.episodeNumber" string The Episode number. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.


    Examples: "3", "Null".

    "c3.cm.genre" string The Primary content genre. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.


    Examples: "Drama", "Null".

    "c3.cm.genreList" string The list of the applicable content genre. Set the values in a comma separated list only if the details cannot be inferred from Asset Provider Server. Null if not applicable.


    Examples: "Drama, Crime, Political, Violence", "Null"

    "c3.cm.utmTrackingUrl" string Provide the UTM parameters in the URL to track the effectiveness of the online marketing campaign across traffic sources and publishing media. Conviva uses CONTAINS logic to parse the individual UTM parameters from the URL provided, so either the full URL or just the UTM parameters is acceptable.


    Example values: http://www.example.com/?utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale&utm_content=toplink or utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale&utm_content=toplink

    This tag is only applicable for web and mobile devices.

    Device Metadata

    By default, Conviva Android SDK autodetects device metadata for Android OS. Device metadata is also used for inferring the device tags dimension. However, if a device is built on a customized version of Android, or certain device information needs to be customized (for example, model or manufactured for Android-based STB), the below API can be used.

    We recommend consulting to your Conviva representative in case you decide to customize your device metadata. Device metadata may or may not be auto-collected by Conviva. For Android, Conviva auto-detects device metadata. Device metadata is also used for inferring the device tags dimensions. If you're implementing Conviva on a Set Top Box or other custom Android device, check the aspects of implementation with your Conviva representative, as it may require setting custom device metadata.

    Device Metadata Instructions (Click to Expand):

    Map<String, Object> deviceInfo = new HashMap<>();
    deviceInfo.put(ConvivaSdkConstants.DEVICEINFO.DEVICE_BRAND, "Google");
    // set the rest of the required metadata fields as per the table below
    ConvivaAnalytics.setDeviceInfo(deviceInfo);
    

    The table below provides the list of pre-defined metadata for device metadata.

    Key Type Description Example Value
    ConvivaSdkConstants.DEVICEINFO.ANDROID_BUILD_MODEL string Android build model "PIXEL 3 XL"
    ConvivaSdkConstants.DEVICEINFO.OPERATING_SYSTEM_VERSION string OS version "10"
    ConvivaSdkConstants.DEVICEINFO.DEVICE_BRAND string Device Brand "Google"
    ConvivaSdkConstants.DEVICEINFO.DEVICE_MANUFACTURER string Device manufacturer "Google"
    ConvivaSdkConstants.DEVICEINFO.DEVICE_MODEL string Device Model "PIXEL"
    ConvivaSdkConstants.DEVICEINFO.DEVICE_TYPE string Device type "Mobile"
    ConvivaSdkConstants.DEVICEINFO.DEVICE_VERSION string Device version "3"

    Custom Metadata

    Custom metadata that allows the implementation of your custom tag keys, specific to your business requirement, for either video or ad content.

    Refer to App Manager-> Metadata -> Custom Metadata page for your account to find the custom tags which shall be implemented.

    Set custom tags in a similar way for either video or ads, by adding the tags to the contentInfo or adInfo objects, passed into corresponding methods of videoAnalytics / adAnalytics objects.

    Conviva recommends to label the custom tags as "MyCustomTag1" or "my_custom_tag", and not use the c3.cm format, for instance, c3.cm.MyCustomTag1. Conviva reserved the c3.cm naming convention for the pre-defined or required metadata.

    Update/Amend Metadata

    The device metadata can be immediately set when the values are available.

    To update or amend pre-defined and custom tags for video, use the videoAnalytics.setContentInfo(contentInfo) object containing the key - value pairs of metadata tags for video content.

    Example usage:

    Map<String, Object> contentInfo = new HashMap<>();
    contentInfo.put(ConvivaSdkConstants.ASSET_NAME, "[channel_id] Live Channel Name");
    // set the values for the other pre-defined keys as appropriate, refer to the tables below
    contentInfo.put("c3.cm.contentType", "Live-Linear");
    // set the values for custom tags as required per definition for your account
    contentInfo.put("my_custom_tag_key", "my_custom_tag_value");
    
    videoAnalytics.setContentInfo(contentInfo);
    

    IMPORTANT: Please note that different Conviva products, such as Conviva VSI and Conviva Viewer Insights may have different logic with respect to handling updated values. Conviva recommends to update the metadata only when it is available and do not set any default values before the metadata is available.

    3. Report Events and Metadata

    Report Video Play Start

    For each video play, report playback attempt requests

    videoAnalytics.reportPlaybackRequested(Map<String, Object> contentInfo)
    

    where contentInfo maps the key - value pairs of metadata tags for video content.

    IMPORTANT: It's critical to make this API call correctly to monitor video experience - monitoring session created from this moment, and key metrics are captured based on this event. For example, if this call done late (say, when video starts rather than user clicks 'play'), the Video Startup Time will be under-reported, Video Start Failures will be missed, etc.

    Please note that each video should be monitored separately - call this method for each new video played.

    IMPORTANT: If some of the content metadata tags aren't available at start, they can be set later or amended by videoAnalytics.setContentInfo(contentInfo) API - refer herefor details.

    Please note, in most cases that it's required to set content metadata before the player reports "play" for the first time, to accurately attribute metadata to the video asset.

    Invoke reportPlaybackRequested() On: Invoke reportPlaybackEnded() On:
    User clicks play button

    User stops the video

    User starts another video

    Video ends

    Video starts in autoplay mode
    User replays video again
    A new video starts in playlist Video item ends in playlist

    Report Ad Breaks to Video Session

    IMPORTANT:The SDK autodetects the reportAdBreakStarted() / reportAdBreakEnded() events in case of the Conviva Ad Modules used.

    Report Ad Break

    To handle ads, inform videoAnalytics object that ad break is started: videoAnalytics.reportAdBreakStarted(ConvivaSdkConstants.AdPlayer adPlayer, ConvivaSdkConstants.AdType adType)

    • adType specifies type of the ad (server side / client side);

    • adPlayer informs Conviva sensor which player is used to play the ads - the same as main video content or separate instance. Depending on that, the videoAnalytics will apply corresponding logic to track it correctly.

    The ideal event for invoking this method is on main video pause, to clear stage for Ad playback.

    If the same video player instance used for ads as for the video, call it when application requests the ads.

    Refer to the below sample code for illustration of how reporting shall be done in these scenarios:

    Client-side Ads

    // Ad Break Start for client side ad insertion with separate player instance for ads
    videoAnalytics.reportAdBreakStarted(ConvivaSdkConstants.AdPlayer.SEPARATE, ConvivaSdkConstants.AdType.CLIENT_SIDE);
    
    // Ad Break Start for client side ad insertion with same player instance for ads
    videoAnalytics.reportAdBreakStarted(ConvivaSdkConstants.AdPlayer.CONTENT, ConvivaSdkConstants.AdType.CLIENT_SIDE);
    

    Server-side Ads

    // Server-side ads are embeded within the main video content
    // Ad Break Start for server-side ads
    videoAnalytics.reportAdBreakStarted(ConvivaSdkConstants.AdPlayer.CONTENT, ConvivaSdkConstants.AdType.SERVER_SIDE);
    

    On ad break ended

    videoAnalytics.reportAdBreakEnded();
    

    Report Video Play End

    For each video play end, report playback ended
    videoAnalytics.reportPlaybackEnded();
    

    4. Integrate Video Players

    Conviva core SDK is universal and player agnostic, therefore it can be used to integrate any video player using the programming language it's written for.

    For ease and speed of integration, Conviva also provides plug-in modules for the most commonly used video players.

    The modules allow to auto-detect events from the particular player.

    If instructions for your player are not shown below, please follow the instructions for "Custom Integration", or contact your Conviva representative.

    ExoPlayer

    This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK. Please note that the legacy SDK is deprecated and is not supported from version 4.0.18 and above.
    This module is compatible only with Media3 ExoPlayer 1.4.0 or below. For later releases, use the Media3 module.

    Conviva ExoPlayer module auto-detects events emitted by ExoPlayer. Therefore, it's not necessary to report these events explicitly by using "reportPlaybackMetric()" API. It's still required to report application events such as backgrounding, metadata, session close, ad-related events.

    Add the Conviva ExoPlayer module dependency

    implementation 'com.conviva.sdk:conviva-exoplayer-sdk:<version>'
    
    As there are backward compatibility issues with different versions of ExoPlayer, we recommend to pick the correct version of Conviva Module by referring to the release notes and the Exoplayer version that your application is using.

    Release Notes: https://github.com/Conviva/conviva-android-exoplayer/blob/master/CHANGELOG.md

    Or download and add the library explicitly from https://github.com/Conviva/conviva-android-exoplayer/releases

    Set player reference to Conviva videoAnalytics

    videoAnalytics.setPlayer(SimpleExoPlayer);
    

    Starting that moment, Conviva library will listen for all relevant events automatically.

    Please include the android.enableDexingArtifactTransform=false property in the gradle.properties file of the application to fix the "Abstract Method Error" exception while the application is running. This exception is caused when the Android dex compiler (latest) ignores the default methods of an interface while packaging.

    Metrics monitored by Conviva ExoPlayer module (if applicable):

    Key Implementation Note
    videoAnalytics.reportPlaybackError() (VSF/VPF) The module listens for the video errors fired by the player.


    To report application level errors impacting user experience, call videoAnalytics.reportPlaybackError(string message) explicitly.

    ConvivaSdkConstants.PLAYBACK. PLAYER_STATE Autocollected.
    All player state changes: Playing, Buffering, Paused.
    ConvivaSdkConstants.PLAYBACK.BITRATE

    Autocollected

    For the Average Peak Bitrate definition, refer to Average Peak Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.AVG_BITRATE

    Autocollected

    For the Avg. Average Bitrate definition, refer to Avg. Average Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED

    Autocollected

    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED Autocollected
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME Autocollected
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH Autocollected
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE Not Collected - limitation
    ConvivaSdkConstants.PLAYBACK.CDN_IP Can be autocollected.
    Please contact Conviva Support to enable auto collection configuration.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Autocollected
    ConvivaSdkConstants.PLAYBACK.AUDIO_LANGUAGE Autocollected
    ConvivaSdkConstants.PLAYBACK.CLOSED_CAPTIONS_LANGUAGE AutoCollected
    ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE Autocollected

    Implement Metadata

    Metadata monitored by Conviva ExoPlayer module (if applicable):

    Key Implementation note
    ConvivaSdkConstants.FRAMEWORK_NAME Autocollected from ExoPlayer.
    ConvivaSdkConstants.FRAMEWORK_VERSION Autocollected from ExoPlayer.
    ConvivaSdkConstants.DURATION Autocollected from ExoPlayer for VOD contents.

    Report the scheduled programming duration for live or linear streams and update it on the program boundaries.

    Click to view the reference implementation:
    Map<String, Object> contentInfo = new HashMap<>();
    contentInfo.put(ConvivaSdkConstants.DURATION, 126);
    videoAnalytics.setContentInfo(contentInfo);
    


    To implement the rest of metadata, refer to the above sections common pre-defined, pre-defined video, and custom metadata definitions for implementation details.

    Known ExoPlayer Limitations

    Metric Impact Conditions Issue
    Average Bitrate Under reported HLS Demuxed Streams Player reports video bitrate but reports 0 for audio.
    Over reported AVERAGE-BANDWIDTH unavailable Player reports peak bitrate if average bitrate information is unavailable in manifest file.
    ExoPlayer does not support DASH Live on Android M.

    Media3

    This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK. Please note that the legacy SDK is deprecated and is not supported from version 4.0.18 and above.
    This Module is NOT compatible with Conviva Core SDK 4.0.44 or below.

    Conviva Media3 module auto-detects events emitted by the Media3 ExoPlayer. Therefore, it's not necessary to report these events explicitly by using "reportPlaybackMetric()" API. It's still required to report application events such as backgrounding, metadata, session close, ad-related events.

    Add the Conviva Media3 module dependency

    implementation 'com.conviva.sdk:conviva-media3-sdk:<version>'
    
    As there are backward compatibility issues with different versions of Media3, we recommend to pick the correct version of Conviva Module by referring to the release notes and the Exoplayer version that your application is using.

    Release Notes: https://github.com/Conviva/conviva-android-media3/blob/master/CHANGELOG.md

    Or download and add the library explicitly from https://github.com/Conviva/conviva-android-media3/releases

    Set player reference to Conviva videoAnalytics

    videoAnalytics.setPlayer(exoPlayer);
    

    Starting that moment, Conviva library will listen for all relevant events automatically.

    Please include the android.enableDexingArtifactTransform=false property in the gradle.properties file of the application to fix the "Abstract Method Error" exception while the application is running. This exception is caused when the Android dex compiler (latest) ignores the default methods of an interface while packaging.

    Metrics monitored by Conviva ExoPlayer module (if applicable):

    Key Implementation Note
    videoAnalytics.reportPlaybackError() (VSF/VPF) The module listens for the video errors fired by the player.


    To report application level errors impacting user experience, call videoAnalytics.reportPlaybackError(string message) explicitly.

    ConvivaSdkConstants.PLAYBACK. PLAYER_STATE Autocollected.
    All player state changes: Playing, Buffering, Paused.
    ConvivaSdkConstants.PLAYBACK.BITRATE

    Autocollected

    For the Average Peak Bitrate definition, refer to Average Peak Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.AVG_BITRATE

    Autocollected

    For the Avg. Average Bitrate definition, refer to Avg. Average Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED

    Autocollected

    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED Autocollected
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME Autocollected
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH Autocollected
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE Not Collected - limitation
    ConvivaSdkConstants.PLAYBACK.CDN_IP Can be autocollected.
    Please contact Conviva Support to enable auto collection configuration.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Autocollected
    ConvivaSdkConstants.PLAYBACK.AUDIO_LANGUAGE Autocollected
    ConvivaSdkConstants.PLAYBACK.CLOSED_CAPTIONS_LANGUAGE AutoCollected
    ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE Autocollected

    Implement Metadata

    Metadata monitored by Conviva ExoPlayer module (if applicable):

    Key Implementation note
    ConvivaSdkConstants.FRAMEWORK_NAME Autocollected from ExoPlayer.
    ConvivaSdkConstants.FRAMEWORK_VERSION Autocollected from ExoPlayer.
    ConvivaSdkConstants.DURATION Autocollected from ExoPlayer for VOD contents.

    Report the scheduled programming duration for live or linear streams and update it on the program boundaries.

    Click to view the reference implementation:
    Map<String, Object> contentInfo = new HashMap<>();
    contentInfo.put(ConvivaSdkConstants.DURATION, 126);
    videoAnalytics.setContentInfo(contentInfo);
    


    To implement the rest of metadata, refer to the above sections common pre-defined, pre-defined video, and custom metadata definitions for implementation details.

    Known ExoPlayer Limitations

    Metric Impact Conditions Issue
    Average Bitrate Under reported HLS Demuxed Streams Player reports video bitrate but reports 0 for audio.
    Over reported AVERAGE-BANDWIDTH unavailable Player reports peak bitrate if average bitrate information is unavailable in manifest file.
    ExoPlayer does not support DASH Live on Android M.

    Custom Integration

    Conviva sensor can be used to integrate video players using explicit metric reporting using the ConvivaVideoAnalytics class methods. The major steps required are listed below.

    Report playback failures

    To report fatal playback error AND quit the session: videoAnalytics.reportPlaybackFailed(String errorMessage, Map contentInfo)

    • errorMessage string is the message specifying the error. Report the reason of the failure, avoid including metadata.

    • contentInfo is optional. If not provided, Conviva sensor will use metadata previously reported by setContentInfo() or metadata passed along with reportPlaybackRequested() call.

    To report fatal playback error AND keep the session open (e.g., in case of player internal re-try or fallback logic):

    videoAnalytics.reportPlaybackError(errorMessage)

    The argument errorMessage has the same meaning as above.

    Example usage:

    // report error and cleanup immediately. The contentInfo provides metadata for the failed video.
    videoAnalytics.reportPlaybackFailed(errorMessage, contentInfo);
    // report the error but keep the session open
    videoAnalytics.reportPlaybackError(errorMessage);
    

    Report playback metrics

    To report metric events:

    videoAnalytics.reportPlaybackMetric(String key, Object val)

    It accepts multiple/zero values for the second argument. The values of the supported "key" argument are defined as Conviva constants (see the below table).

    The keys are pre-defined in the ConvivaSdkConstants.PLAYBACK enum.

    Example usage:

    // integer parameter in kbps for this key ConvivaSdkConstants.PLAYBACK.BITRATE
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.BITRATE, 3600);
    

    The table below defines the events required to be implemented, with the corresponding parameters for each event key.

    Key Type Implementation Note
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE *enum ConvivaSdkConstants.PlayerState.* Report any player state changes such as Playing, Buffering, Paused.
    ConvivaSdkConstants.PLAYBACK.BITRATE *int (kbps)*

    Report new peak bitrate value on change event (video + audio, or video only if audio isn't available).

    For the Average Peak Bitrate definition, refer to Average Peak Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.AVG_BITRATE *int (kbps)*

    Report new average bitrate value on change event (video + audio, or video only if audio isn't available).

    For the Avg. Average Bitrate definition, refer to Avg. Average Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED *Optional: int (ms)* Report start of seeking or scrubbing by user. If seek position is known, report as the method argument.
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED no argument Report end of seeking or scrubbing by user
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME *long (ms)* Report current playback position.
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH *long (ms)* Report current Buffer length of the player.
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE *long (fps)* Report rendered framerate in fps.
    ConvivaSdkConstants.PLAYBACK.CDN_IP *string (IP address)* Report CDN IP address in string format.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT *int (drop frame count)* Report the periodic dropped frames count for a specific time interval.
    ConvivaSdkConstants.PLAYBACK.AUDIO_LANGUAGE String Report the audio language code and name in the [langCode]:langName format, for example, [en]:English. When only one of them is available, report it as such, for example,en or English.
    ConvivaSdkConstants.PLAYBACK.CLOSED_CAPTIONS_LANGUAGE String Report the closed captions language code and name in the [langCode]:langName format, for example, [en]:English. When only one of them is available, report it as such, for example, en or English.
    ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE String Report the subtitles language code and name in the [langCode]:langName format, for example, [en]:English. When only one of them is available, report it as such, for example, en or English.

    IMPORTANT: At any given time, a player can report the language of either the subtitles or the closed captions. When it reports one of them, the other language is set to off if it has already been reported. Report these languages (if they're available) on session start as well as when the user changes them on the current playback. Example:

    // report closed_captions_language = "[en]:English" (language code and name are available)
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.CLOSED_CAPTIONS_LANGUAGE, "[en]:English");
    // report the subtitles_language = "fr" (consider only language code is available)
    // reporting the subtitles will set the previously-reported closed_captions_language = "off"
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE, "fr");
    

    If the audio, subtitle, or closed captions language option was initially enabled but later disabled, ensure to report the most recent language option value as off. Example:

    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE, "off");
    

    Implement Callback function for polled metrics

    There are certain metrics which do not have events, hence SDK provides a callback to update these values at a certain frequency. Once player has been initialized, implement an ICallback interface for the player in the main thread so that the SDK can get continuous measures of the player such as, play head time, buffer length and rendered framerate.

    Since this API callback is called every 1 sec, it is recommended that no other metrics than the one specified be updated. It must not retain strong references to instances in outer scopes.
    // Syntax of the API to register the ICallback interface used to invoke for every 1 sec by Conviva
    void setCallback(ICallback callback);
    
    // Sample code snippet
    ConvivaExperienceAnalytics.ICallback callback = new ConvivaExperienceAnalytics.ICallback() {
    @Override public void update() {
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH, 30000);
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME, 10000);
    videoAnalytics.reportPlaybackMetric(ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, 20);
    }
    };
    videoAnalytics.setCallback(callback);
    

    Implement Metadata

    For Custom Integration, Conviva sensor does not capture any metadata automatically.

    Refer to the above sections common pre-defined, pre-defined video, and custom metadata definitions for implementation details.

    NexStreaming

    This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK.

    Conviva NexStreaming module auto-collects video events emitted by the NexStreaming player. Therefore, it's not necessary to report these events explicitly by using "reportPlaybackMetric()" API. It's still required to report application events such as backgrounding, metadata, session close, ad-related events.

    Add the Conviva NexStreaming module dependency

    implementation 'com.conviva.sdk:conviva-nexplayer-sdk:<version>'
    

    To download and add the library explicitly from Conviva GitHub, refer:

    https://github.com/Conviva/conviva-android-nexstreaming

    Set player reference to Conviva videoAnalytics

    videoAnalytics.setPlayer(nexPlayer);
    

    Starting at that moment, Conviva library will listen for all events automatically.

    Metrics monitored by Conviva NexStreaming module (if applicable):

    Key Implementation Note
    videoAnalytics.reportPlaybackError() (VSF/VPF) The module autocollects video errors fired by the player.
    To report application level errors impacting user experience, call videoAnalytics.reportPlaybackError(string message) explicitly.
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE Autocollected.
    All player state changes: Playing, Buffering, Paused.
    ConvivaSdkConstants.PLAYBACK.BITRATE Autocollected
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED Autocollected
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED Autocollected
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME Autocollected
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH Autocollected
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE Autocollected
    ConvivaSdkConstants.PLAYBACK.CDN IP CDN IP address in string format. Can be autocollected
    Please contact Conviva Support to enable auto collection configuration.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Autocollected

    Implement Metadata

    Metadata monitored by Conviva NexStreaming module (if applicable):

    Key Implementation note
    ConvivaSdkConstants.FRAMEWORK_NAME Autocollected from NexStreaming.
    ConvivaSdkConstants.FRAMEWORK_VERSION Autocollected from NexStreaming.

    To implement the rest of metadata, refer to the above sections common pre-defined, pre-defined video, and custom metadata definitions for implementation details.

    Known NexStreaming Limitations

    Metric Impact Conditions Issue
    Play State Over reported Pause on low bandwidth When the user pauses the content due to low bandwidth, the player reports PLAY state before reporting PAUSE state.
    Pause State Under reported Pause on low bandwidth When the user pauses the content due to low bandwidth, the player reports PLAY state before reporting PAUSE state.
    Rebuffering Ratio Under reported Progressive Download (MP4) on low bandwidth When the user seeks under low bandwidth, the player freezes, but starts reporting a PLAY state and sends onBufferingEnd(). In this scenario, Conviva buffering metrics are under-reported.
    Video Restart Time (VRT) Not reported Progressive Download (MP4) on low bandwidth When the user seeks under low bandwidth, the player freezes but starts reporting a PLAY state and sends onBufferingEnd(). In this scenario, VRT will not be reported.
    Average Bitrate Incorrect HLS Demux Stream When playing a HLS demux stream, the player reports incorrect audio bitrate.

    Brightcove

    This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK.

    Conviva Brightcove module auto-detects events emitted by Brightcove player. Therefore, it's not necessary to report these events explicitly by using "reportPlaybackMetric()" API. It's still required to report application events such as backgrounding, metadata, session close, ad-related events.

    Add the Conviva Brightcove module dependency

    implementation 'com.conviva.sdk:conviva-brightcove-sdk:<version>'
    

    To download and add the library explicitly from Conviva GitHub, refer:

    https://github.com/Conviva/conviva-android-brightcove

    Set player reference to Conviva videoAnalytics using this API

    videoAnalytics.setPlayer(brightcovePlayer);
    

    The argument brightcovePlayer is the instance of BrightcoveVideoView or BrightcoveExoPlayerVideoView.

    Starting that moment, Conviva library will listen for all relevant events automatically.

    Metrics monitored by Conviva Brightcove module (if applicable):

    Key Implementation Note
    videoAnalytics.reportPlaybackError() (VSF) The module autocollects the video errors fired by the player.
    Neither BrightcoveExoPlayerVideoView nor BrightcoveVideoView report errors in case of mid-stream failure. Impacts VPF reporting (underreported).
    To report application level errors impacting user experience, call videoAnalytics.reportPlaybackError(string message) explicitly.
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE Autocollected.
    All player state changes: Playing, Buffering, Paused.
    ConvivaSdkConstants.PLAYBACK.BITRATE

    Autocollected

    For the Average Peak Bitrate definition, refer to Average Peak Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.AVG_BITRATE

    Autocollected

    For the Avg. Average Bitrate definition, refer to Avg. Average Bitrate in Metric Dictionary.

    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED Autocollected
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED Autocollected
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME Autocollected
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH Not collected - limitation
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE Not collected - limitation
    ConvivaSdkConstants.PLAYBACK.CDN_IP Can be autocollected for BrightcoveExoPlayerVideoView, not supported for BrightcoveVideoView.
    Please contact Conviva Support to enable auto collection configuration.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Autocollected
    Supported for BrightcoveExoPlayerVideoView, not supported for BrightcoveVideoView.
    ConvivaSdkConstants.PLAYBACK.AUDIO_LANGUAGE Autocollected
    Supported for BrightcoveExoPlayerVideoView, not supported for BrightcoveVideoView.
    ConvivaSdkConstants.PLAYBACK.CLOSED_CAPTIONS_LANGUAGE Autocollected
    Supported for BrightcoveExoPlayerVideoView, not supported for BrightcoveVideoView.
    ConvivaSdkConstants.PLAYBACK.SUBTITLES_LANGUAGE Autocollected
    Supported for BrightcoveExoPlayerVideoView, not supported for BrightcoveVideoView.

    Implement Metadata

    Metadata monitored by Conviva Brightcove module (if applicable):

    Key Implementation note
    ConvivaSdkConstants.FRAMEWORK_NAME Autocollected from Brightcove.
    ConvivaSdkConstants.FRAMEWORK_VERSION Autocollected from Brightcove.

    To implement the rest of metadata, refer to the above sections common pre-defined, pre-defined video, and custom metadata definitions for implementation details.

    Known Brightcove Limitations

    Metric Impact Conditions Issue
    Subtitle and Audio Languages Reported Same BrightcoveExoPlayerVideoView For subtitles and closed captions, the player reports language code for both the code and name fields, for example, [en]:en, [fr]:fr, or [es]:es.
    Not Autocollected BrightcoveExoPlayerVideoView The selection of *none* or *off* for subtitles or closed captions is not auto-collected.
    Average Bitrate Not reported
    • Brightcove VideoView for HLS and MP4.

    • BrightcoveExoPlayerVideoView for MP4.

    Bitrate information cannot be automatically detected via the API.
    Under-reported BrightcoveExoPlayerVideoView for HLS Demuxed Streams. Player reports video bitrate but reports 0 for audio.
    Video Playback Failures (VPF) Under-reported BrightcoveExoPlayerVideoView/BrightcoveVideoView URL unreachable for MP4. When the URL is unreachable mid-stream, the player does not report any fatal errors for MP4 streams.
    CDN IP Not reported BrightcoveVideoView CDN Edge Server IP auto detection is not supported for BrightcoveVideoView player.
    CDN Edge Server IP auto collection is supported for BrightcoveExoPlayerVideoView player.

    Seek Events

    (PSS & PSE)

    Over reported BrightcoveVideoView or BrightcoveExoPlayerVideoView

    Multiple PSS and PSE events are reported when we seek through the seek bar after:

    • The orientation changes from landscape to portrait or vice versa.

    • Switching between content and ads

    Dropped Frame Count Not reported BrightcoveVideoView

    Dropped Frame Count auto detection is not supported for BrightcoveVideoView player.

    Dropped Frame Count auto collection is supported for BrightcoveExoPlayerVideoView player.
    BrightCoveVideoView offers limited support for HLS.
    After integrating the video player, review advanced use cases such as live program and playlist changes, fatal errors, and foreground and background actions that can be applicable for specific goals.

    Integrate Ad Managers

    Conviva core SDK is universal and player agnostic, therefore it can be used to integrate any Ad SDK using the programming language it's written for.

    For ease and speed of integration, Conviva also provides plug-in modules for the most common Ad SDKs.

    The modules allow to auto-detect events from the particular player / Ad SDK.

    If instructions for your Ad SDK are not shown below, please follow the instructions for "Custom Ad Manager" integration, or contact your Conviva representative.

    Google IMA/DAI

    This documentation is for Android SDK 4.0.2 and above. If you are using the legacy SDK, we highly recommend you upgrade to the new SDK. Please note that the legacy SDK is deprecated and is not supported from version 4.0.18 and above.

    Conviva provides the module to auto-detect ad events emitted by the Google IMA SDK. Therefore, it's not necessary to report these events explicitly by using core SDK APIs. It's still required to report application events such as backgrounding.

    The Android IMA/DAI module supports both Client Side and Server Side ad technologies.

    Add the Conviva IMA/DAI module dependency

    implementation 'com.conviva.sdk:conviva-ima-sdk:<version>'
    

    Or download and add the library explicitly:

    https://github.com/Conviva/conviva-android-imasdk

    Set Ad Listener to AdAnalytics

    To enable Ad metric & metadata auto-detection, pass the adsLoader instance of the IMA SDK to Conviva adAnalytics:

    Map<String, Object> info = new HashMap<>();
    //if adTagurl is known prior
    info.put(ConvivaSdkConstants.AD_TAG_URL, “adTagUrl”);
    
    //Below code is applicable only if you are using client side ads.
    //The second argument can be ConvivaSdkConstants.AdPlayer.CONTENT or ConvivaSdkConstants.AdPlayer.SEPARATE
    // Pass "CONTENT" if ads and main video use the same player, and "SEPARATE" otherwise.
    info.put(ConvivaSdkConstants.AD_PLAYER, ConvivaSdkConstants.AdPlayer.CONTENT.toString());
    
    
    //if preloading is enabled
    info.put(ConvivaSdkConstants.AD_PRELOAD_FEATURE, true);
    
    // This API is used to initialise the IMA/DAI module and registers listeners for ad playback
    adAnalytics.setAdListener (adsLoader, info); //info is optional here.
    

    Starting that moment, Conviva IMA/DAI module will listen for all relevant events automatically.

    The constants below are defined in the class com.conviva.sdk.ConvivaSdkConstants.

    Metrics monitored by Conviva Google IMA module (if applicable):

    Key Implementation Note
    adAnalytics.reportAdError() (ASF/APF) The module listens for the ad errors fired by the player. To report application level errors impacting user experience, call adAnalytics.reportAdError(String message) explicitly.
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE Autocollected
    ConvivaSdkConstants.PLAYBACK.BITRATE Autocollected
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED

    Report if the application implementation supports detecting start of seeking or scrubbing by user, as Google IMA doesn't support seek during ads by default. If seek position is known, report as the method argument.

    Reference implementation:

    adAnalytics.reportAdMetric(
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED, 10000);
    
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED

    Report if the application implementation supports detecting end of seeking or scrubbing by user, as Google IMA doesn't support seek during ads by default.

    Reference implementation:

    adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.SEEK_ENDED);
    
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME

    Report if the application implementation supports collecting play head time, as Google IMA doesn't support API for fetching play head time by default.

    adAnalytics.reportAdMetric(
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME, 10000);
    
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH

    Report if the application implementation supports collecting buffer length, as Google IMA doesn't support API for fetching buffer length by default.

    Reference implementation:

    adAnalytics.reportAdMetric(
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH, 10000);
    
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE

    Report if the application implementation supports collecting rendered framerate, as Google IMA doesn't support API for fetching rendered framerate by default.

    Reference implementation:

    adAnalytics.reportAdMetric(
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, 20);
    
    ConvivaSdkConstants.PLAYBACK.CDN_IP Report CDN IP address in string format.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Report periodic dropped frames count for a specific time interval.

    Metrics monitored by Conviva Google DAI module (if applicable):

    Key Implementation Note
    adAnalytics.reportAdError() (ASF/APF) The module listens for the ad errors fired by the player. To report application level errors impacting user experience, call adAnalytics.reportAdError(String message) explicitly.
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE Autocollected.
    ConvivaSdkConstants.PLAYBACK.BITRATE

    Autocollected if any Conviva Video player module is used. Report if custom integration is used.

    Reference implementation:

    videoAnalytics.reportPlaybackMetric(
    ConvivaSdkConstants.PLAYBACK.BITRATE, 2200);
    
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED

    Report if the application implementation supports detecting start of seeking or scrubbing by user, as Google IMA doesn't support seek during ads by default. If seek position is known, report as the method argument.

    videoAnalytics.reportPlaybackMetric(
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED, 10000);
    
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED

    Report if the application implementation supports detecting end of seeking or scrubbing by user, as Google IMA doesn't support seek during ads by default.

    Reference implementation:

    videoAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.SEEK_ENDED);
    
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH

    Report if the application implementation supports collecting buffer length, as Google IMA doesn't support API for fetching buffer length by default.

    Reference implementation:

    videoAnalytics.reportPlaybackMetric(
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH, 10000);
    
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE

    Report if the application implementation supports collecting rendered framerate, as Google IMA doesn't support API for fetching rendered framerate by default.

    Reference implementation:

    videoAnalytics.reportPlaybackMetric(
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, 20);
    
    ConvivaSdkConstants.PLAYBACK.CDN_IP Report CDN IP address in string format.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT Report periodic dropped frames count for a specific time interval.

    Implement Ad Metadata

    Conviva defines the set of the metadata keys to be used for metadata implementation. The implementation can be extended by adding custom tags - refer to Custom Metadata section.

    The Conviva IMA/DAI module automatically collects the available values for some of the metadata tags from the IMA SDK.

    Some of the tags though still have to be explicitly implemented. Please refer to the table below for the metadata tag definitions and details of the implementation. No action required if implementation note says "Autocollected".

    Key Type Implementation note
    ConvivaSdkConstants.STREAM_URL string Report the value using ConvivaSdkConstants.AD_TAG_URL of adAnalytics.setAdListener(). If not specified, autocollected as the same value from videoAnalytics.
    ConvivaSdkConstants.ASSET_NAME string Autocollected using ad.getTitle().
    ConvivaSdkConstants.IS_LIVE string Autocollected as the same value from videoAnalytics.
    ConvivaSdkConstants.PLAYER_NAME string Autocollected as the same value from videoAnalytics - no need to set explicitly for adAnalytics.
    ConvivaSdkConstants.VIEWER_ID string Autocollected as the same value from videoAnalytics.
    ConvivaSdkConstants.DURATION integer Autocollected using ad.getDuration().
    ConvivaSdkConstants.ENCODED_FRAMERATE integer Autocollected as the same value from videoAnalytics.
    "c3.app.version" string Autocollected.

    If you want to set it manually, report application build version from the application. Shall have the same value for both ads and video.

    Pre-defined Ad Metadata:

    Key Type Implementation note
    "c3.ad.technology" string Autocollected as "Client Side/Server Side".
    "c3.ad.id" string Autocollected as VAST Ad ID using ad.getAdId(), if the API fails is set to default “NA” value. Not applicable for slates.
    "c3.ad.system" string Autocollected as VAST Ad System using ad.getAdSystem(), if the API fails is set to default “NA” value. Not applicable for slates.
    "c3.ad.position" string Autocollected using ad.getAdPodInfo().getPodIndex(). Reported as “Pre-roll” for preroll ads, “Mid-roll” for both midroll and postroll ads for DAI VOD streams. Reported as “Mid-roll” by default for DAI Live streams and slates.
    "c3.ad.isSlate" string Autocollected for SSAI as “true” for slates and “false” for ads. Only applicable for SSAI.
    "c3.ad.mediaFileApiFramework" string Autocollected as VAST mediaFileApiFramework.
    "c3.ad.adStitcher" string Autocollected as "Google DAI" for SSAI.
    "c3.ad.firstAdSystem" string Autocollected using ad.getWrapperAdSystems()[len-1] when there is wrapper response, else from ad.getAdSystem().
    Otherwise, reported as “NA” if value is not available.


    Not applicable for slates.

    "c3.ad.firstAdId" string Autocollected using ad.getWrapperAdIds()[len-1] when there is wrapper response, else from ad.getAdId().
    Otherwise, reported as “NA” if value is not available.


    Not applicable for slates.

    "c3.ad.firstCreativeId" string Autocollected using ad.getWrapperCreativeIds()[len-1] when there is wrapper response, else from ad.getCreativeId().
    Otherwise, reported as “NA” if value is not available.


    Not applicable for slates.

    "c3.ad.creativeId" string Autocollected using ad.getCreativeId().
    Otherwise, reported as “NA” if value is not available.


    Not applicable for slates.

    implementation 'com.conviva.sdk:conviva-exoplayer-ima-sdk:4.0.0'
    

    Or download and add the library explicitly:

    https://github.com/Conviva/conviva-android-exoplayer-imasdk

    Initialize

    To enable auto-collection of metrics and events, set up the module by passing the corresponding to Conviva:

    • For CSAI:

    com.google.android.exoplayer2.ext.ima.ImaAdsLoader

    • For SSAI/DAI:

    com.google.android.exoplayer2.ext.ima.ImaServerSideAdInsertionMediaSource.AdsLoader

    (Optional) If the application needs to listen ad events, pass the AdModuleListener instance to Conviva.

    Integrating this Conviva module will replace any existing AdEventListener and AdErrorListener set on the ImaAdsLoader instance.
    ConvivaVideoAnalytics videoAnalytics = ConvivaAnalytics.buildVideoAnalytics(context);
    ConvivaAdAnalytics adAnalytics = ConvivaAnalytics.buildAdAnalytics(context, videoAnalytics);
    Map<String, Object> adMetadata = new HashMap<>();
    adMetadata.put(ConvivaSdkConstants.AD_TAG_URL, adUrl); // Required in case of CSAI
    adAnalytics.setAdPlayerInfo(adMetadata);
    
    adAnalytics.setAdListener(
    adsLoader, // ImaAdsLoader in case of CSAI / ImaServerSideAdInsertionMediaSource.AdsLoader in case of SSAI
    moduleListener, // Optional listener to receive ad events, omit if not needed
    adMetadata
    );
    
    Only in case of CSAI, provide the Ad Tag URL in the ad metadata using the key ConvivaSdkConstants.AD_TAG_URL. It is not required in case of SSAI/DAI.

    Know the Limitations

    • For the final mid-roll before the end of the content/post roll, the ad session might not end if the ad playback is triggered by a user seek.

    • For SSAI / DAI, a zero to 2 seconds delay might be observed, which is a limitation of the paradigm itself.

    Media3 IMA Extension

    This module is compatible with Media3 version 1.8.0 and and Conviva Core SDK version 4.0.49 and above.

    Conviva provides this module to support video analytics for applications using the IMA Extension of Media3. This module facilitates auto-collection of all possible metrics in addition to player state changes.

    Add Gradle Dependancy

    Add the following dependency to the build.gradle file:

    implementation 'com.conviva.sdk:conviva-media3-ima-sdk:4.0.0'
    

    Or download and add the library explicitly:

    https://github.com/Conviva/conviva-android-media3-imasdk

    To enable auto-collection of metrics and events, set up the module by passing the corresponding to Conviva:

    • For CSAI: androidx.media3.exoplayer.ima.ImaAdsLoader

    • For SSAI/DAI:

    androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource.AdsLoader

    (Optional) If the application needs to listen ad events, pass the AdModuleListener instance to Conviva.

    Integrating this Conviva module will replace any existing AdEventListener and AdErrorListener set on the ImaAdsLoader instance.
    ConvivaVideoAnalytics videoAnalytics = ConvivaAnalytics.buildVideoAnalytics(context);
    ConvivaAdAnalytics adAnalytics = ConvivaAnalytics.buildAdAnalytics(context, videoAnalytics);
    Map<String, Object> adMetadata = new HashMap<>();
    adMetadata.put(ConvivaSdkConstants.AD_TAG_URL, adUrl); // required for CSAI
    adAnalytics.setAdPlayerInfo(adMetadata);
    
    adAnalytics.setAdListener(
    adsLoader, // ImaAdsLoader in case of CSAI / ImaServerSideAdInsertionMediaSource.AdsLoader in case of SSAI
    moduleListener, // Optional listener to receive ad events, omit if not needed
    adMetadata
    );
    
    Only in case of CSAI, provide the Ad Tag URL in the ad metadata using the key ConvivaSdkConstants.AD_TAG_URL. It is not required in case of SSAI/DAI.

    Know the Limitations:

    For SSAI / DAI, a zero to 2 seconds delay might be observed, which is a limitation of the paradigm itself.

    Custom Ad Manager

    Report Ad Lifecycle Events

    In case of Custom Ad Manager integration, Conviva does not detect any ad metrics or events.

    Implement the following ad events from your application to Conviva:

    • adAnalytics.reportAdLoaded(Map adInfo); // invoke on ad load complete

    • adAnalytics.reportAdStarted(Map adInfo); // invoke on ad playback start

    • adAnalytics.reportAdFailed(String errorMessage, Map adInfo); // invoke when ad fails to load/play

    • adAnalytics.reportAdSkipped();// user skipped the ad

    • adAnalytics.reportAdEnded();// ad playback completed

    In the above methods, the parameter adInfo is a map containing the key - value pairs of metadata tags for ad content.

    Implement it with respect to the requirements prescribed in the next step.

    Implement Ad Metadata

    In case of Custom Ad integration, Conviva does not automatically collect ad metadata, except a few fields for common metadata pulled from the videoAnalytics object automatically.

    Implement the pre-defined common and ad metadata specified in the table below.

    The constants below are defined in the class com.conviva.sdk.ConvivaSdkConstants.

    Pre-defined Common Metadata:

    Key Type Implementation note
    ConvivaSdkConstants.STREAM_URL string The manifest URL of the ad stream.
    ConvivaSdkConstants.ASSET_NAME string Use ad title or "[ad_id] ad_title".
    ConvivaSdkConstants.IS_LIVE string Set the same value as for videoAnalytics.
    ConvivaSdkConstants.PLAYER_NAME string The value is autocollected from videoAnalytics object - no need to pass for adAnalytics.
    ConvivaSdkConstants.VIEWER_ID string The value is autocollected from videoAnalytics object - no need to pass for adAnalytics.
    ConvivaSdkConstants.DEFAULT_RESOURCE string Ad server resource the stream is played from. Set this field when the video server resource cannot be inferred from the STREAM_URL.
    ConvivaSdkConstants.DURATION integer Duration of the single ad clip, in seconds. For example, in a block of 3 ads each 30 seconds long, report 30 sec for each corresponding ad.
    ConvivaSdkConstants.ENCODED_FRAMERATE integer Encoded frame rate of the ad stream in frames per second.
    ConvivaSdkConstants.FRAMEWORK_NAME string Ad Player Framework Name.
    ConvivaSdkConstants.FRAMEWORK_VERSION string Ad Player Framework Version.
    "c3.app.version" string Application build version. Shall have the same value as for the videoAnalytics.

    Pre-defined Ad Metadata:

    Key Type Implementation note
    "c3.ad.technology" string Set the technology of the ad belongs to. Allowed values: "Server Side" and "Client Side".
    "c3.ad.id" string The Ad ID extracted from the Ad Server that actually has the ad creative. For wrapper ads, this is the last Ad ID at the end of the wrapper chain. Example: "411687224".
    "c3.ad.system" string The name of the Ad System (i.e. the Ad Server). This Ad System represents the Ad Server that actually has the ad creative. For wrapper ads, this is the last Ad System at the end of the wrapper chain. Set to "NA" if not available. Examples: "Freewheel", "Innovid", "Extreme IO", "NA".
    "c3.ad.position" string The position of the ad. Allowed values are "Pre-roll", "Mid-roll" and "Post-roll".
    "c3.ad.isSlate" string A boolean value that indicates whether this ad is a Slate or not. Set to "true" for Slate and "false" for a regular ad. By default, set to "false".
    "c3.ad.mediaFileApiFramework" string The name of the creative media framework. Generally used for VPAID ads. Set to "NA" for non-VPAID ads. Examples: "VPAID", "NA".
    "c3.ad.adStitcher" string The name of the Ad Stitcher. If not using an Ad Stitcher, set to "NA". Examples: "Uplynk", "Google DAI", "Google Anvato", "YoSpace", "NA"
    "c3.ad.firstAdSystem" string Only valid for wrapper VAST responses. This tag must capture the "first" Ad System in the wrapper chain when a Linear creative is available or there is an error at the end of the wrapper chain. Set to "NA" if not available. If there is no wrapper VAST response then the Ad System and First Ad System should be the same. Examples: "GDFP", "NA".
    "c3.ad.firstAdId" string Only valid for wrapper VAST responses. This tag must capture the "first" Ad Id in the wrapper chain when a Linear creative is available or there is an error at the end of the wrapper chain. Set to "NA" if not available. If there is no wrapper VAST response then the Ad Id and First Ad Id should be the same. Examples: "709684096", "NA".
    "c3.ad.firstCreativeId" string Only valid for wrapper VAST responses. This tag must capture the "first" Creative Id in the wrapper chain when a Linear creative is available or there is an error at the end of the wrapper chain. Set to "NA" if not available. If there is no wrapper VAST response then the Ad Creative Id and First Ad Creative Id should be the same. Examples: "57861167296", "NA".
    "c3.ad.creativeId" string The creative id of the ad. This creative id is from the Ad Server that actually has the ad creative. For wrapper ads, this is the last creative id at the end of the wrapper chain. Set to "NA" if not available. Examples: "57861167296", "NA".

    Report Ad Metrics

    Report Ad-video metrics to adAnalytics by using: adAnalytics.reportAdMetric(String key, Object... value)

    Example code illustrating how to set the metric:

    adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.BITRATE, 1024);
    

    Refer to the list of metric keys to be implemented in the table below:

    Key Type Implementation Note
    ConvivaSdkConstants.PLAYBACK.PLAYER_STATE *enum ConvivaSdkConstants.PlayerState.* Any player state changes such as Playing, Buffering, Paused shall be reported to CONVIVA SDK.
    ConvivaSdkConstants.PLAYBACK.BITRATE *int (kbps)* Report new bitrate value on change event (video + audio, or video only if audio isn't available)
    ConvivaSdkConstants.PLAYBACK.SEEK_STARTED *Optional: int (ms)* Start of seeking or scrubbing by user. If seek position is known, report as the method argument.
    ConvivaSdkConstants.PLAYBACK.SEEK_ENDED no argument End of seeking or scrubbing by user
    ConvivaSdkConstants.PLAYBACK.PLAY_HEAD_TIME *long (ms)* Current playback position.
    ConvivaSdkConstants.PLAYBACK.BUFFER_LENGTH *long (ms)* Report current Buffer length of the player.
    ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE *long (fps)* Rendered framerate in fps.
    ConvivaSdkConstants.PLAYBACK.CDN_IP string (IP address) CDN IP address in string format.
    ConvivaSdkConstants.PLAYBACK.DROPPED_FRAMES_COUNT int (drop frame count) Report periodic dropped frames count for a specific time interval.

    API Diagrams for Custom Ad Integration

    Click an image to view the API call sequence:

    **CSAI** **SSAI**
    • NM* - During the Non-monitoring state, while the ad plays, the main video is not tracked. However, the ad metrics are tracked in Ad Experience and reported in Pulse Ad Metrics.

    • Ad Session is Ad Attempt to Ad End. Ad Actual Play Time is Ad Play to Ad End. Total Ad Duration is Ad Start to Ad End.

    • Reporting Ad Pod/Break Start and Ad Pod/Break End can provide additional insights about ad pods in the Conviva VSI Overview dashboard Improvement Opportunities data.

    • Stitched ad events are included in the video stream tracking.

    • Ad session is from Ad Start to Ad End.

    • Ad Actual Play Time is from Ad Play to Ad End.

    • For SSAI because AST is short, Ad Duration typically equals Ad Actual Play Time.

    • Ad errors are reported in both video sessions and Ad sessions.

    • Reporting Ad Pod/Break Start and Ad Pod/Break End can provide additional insights in the Conviva VSI Overview dashboard Improvement Opportunities data. Ad metrics are also tracked in Ad Experience and reported in Pulse ad metrics.

    Conviva Ad modules autocollect most of the metrics and metadata. For more details, contact your Conviva representative.

    5. Handle User Actions

    Handle specific user actions such as:

    • App backgrounding or foregrounding

    • Dialogues

    • Pin popups

    • Startover dialogues

    • Video slates

    Use the corresponding API as prescribed on the corresponding pages.

    User Actions: Backgrounding

    Handle backgrounding event (e.g., "home"/"power off" buttons)

    ConvivaAnalytics.reportAppBackgrounded();
    

    On foregrounding

    ConvivaAnalytics.reportAppForegrounded();
    
    Conviva Android Core SDK v4.0.32 and above versions autocollect the app backgrounding and foregrounding events.

    User Actions: User Dialogue

    User Dialogues such as:

    • Pin popup

    • Accepting strong language / violence

    • Confirming age

    • Startover / resume dialogue

    Use this API on dialogue shown

    videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.Events.USER_WAIT_STARTED.toString());
    
    Use this API on dialogue dismiss
    videoAnalytics.reportPlaybackEvent(ConvivaSdkConstants.Events.USER_WAIT_ENDED.toString());
    

    Data Saver

    The Conviva sensor is designed in accordance with the Data Saver capabilities of Android N. When a user enables Data Saver in Settings and the device is on a metered network, the system blocks background data usage and signals apps to use less data in the foreground wherever possible.

    If Data Saver setting is enabled and the app is in the allowed list, the Conviva sensor will continue to send heartbeats as the application is allowed to use data even on metered network. But if the app is not in the allowed list or is blocked, no heartbeat will be sent in the foreground as well as the background.

    Conviva does monitor the change in the Data Saver settings during a running instance of the application and acts accordingly.

    Report Network Metrics

    If the necessary permissions are not added in the application's manifest file, the Conviva library will report the default values, after performing the necessary security checks.

    To enable the Conviva library to collect the network metrics, the application must follow the Android permission instructions provided below

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    
    • In Android M and later versions (API 23 and above), please add a runtime permission request for android.permission.ACCESS_COARSE_LOCATION.

    • In Android Q and later versions (API 29 and above), please add a runtime permission request for android.permission.ACCESS_FINE_LOCATION.

    For more details, see Android permissions.

    if (Build.VERSION.SDK_INT >= 23) {
    if (!(checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
    requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 0);
    }
    }
    
    if (Build.VERSION.SDK_INT >= 29) {
    if ( !(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
    requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
    }
    }
    

    List of metrics that require permissions and collection:

    Metric Permission Required Automatically Collected
    Data Saver android.permission.ACCESS_NETWORK_STATE No
    Connection Type android.permission.ACCESS_NETWORK_STATE

    android.permission.READ_PHONE_STATE

    Yes
    The Conviva sensor will report raw values returned by the Connection Type. Connection type can be updated after session creation, before the first video frame is rendered.
    Link Encryption android.permission.ACCESS_WIFI_STATE

    Yes

    Link Encryption is unavailable since Android Q.
    Wi-Fi Signal Strength android.permission.ACCESS_WIFI_STATE Yes
    Android SDK reports signal strength in decibel-milliwatts (dBm). If the information is not available, the default value is 1000.
    Cellular Signal Strength android.permission.ACCESS_COARSE_LOCATION


    android.permisson.ACCESS_FINE_LOCATION

    Yes
    Android SDK reports signal strength in decibel-milliwatts (dBm). If the information is not available, the default value is 1000.

    Cellular Signal Strength for WCDMA

    Android SDK provides support for WCDMA signal strength from Android API 18 onwards, therefore Conviva sensor will not be able to report it below API level 18.

    • Android L devices: Signal strength information for cellular networks in not available in Android L devices therefore Conviva sensor will not be able to report it. This is also captured as Google Android Issue: 60430.

    • Android Q and above devices: With the release of Android 29, the functionality of the getAllCellInfo() API used for fetching the cellular networks signal strength information has changed. Your applications must add a new permission ACCESS_FINE_LOCATION for all devices using Android Q and above.

    If you are not using these permissions, then they can be excluded by making the below changes in the app.

    Declare tools under manifest root tag

    xmlns:tools=http://schemas.android.com/tools
    

    Add permissions to be excluded

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" tools:node="remove"/>
    

    Network Type

    In most cases, the Conviva library will automatically detect the network type. It will return raw values, based on the mappings below.

    Raw Value (String) Significance Mapping
    0 NETWORK_TYPE_UNKNOWN Unknown
    1 NETWORK_TYPE_GPRS 2G
    2 NETWORK_TYPE_EDGE 2G
    3 NETWORK_TYPE_UMTS 3G
    4 NETWORK_TYPE_CDMA 2G
    5 NETWORK_TYPE_EVDO_0 3G
    6 NETWORK_TYPE_EVDO_A 3G
    7 NETWORK_TYPE_1xRTT 3G
    8 NETWORK_TYPE_HSDPA 3G
    9 NETWORK_TYPE_HSUPA 3G
    10 NETWORK_TYPE_HSPA 3G
    11 NETWORK_TYPE_IDEN 2G
    12 NETWORK_TYPE_EVDO_B 3G
    13 NETWORK_TYPE_LTE 4G
    14 NETWORK_TYPE_EHRPD 3G
    15 NETWORK_TYPE_HSPAP 3G
    16 NETWORK_TYPE_GSM 2G
    17 NETWORK_TYPE_TD_SCDMA 3G
    18 NETWORK_TYPE_IWLAN IWLAN
    20 NETWORK_TYPE_NR 5G
    WiFi CONNECTION_TYPE_WIFI WiFi
    Ethernet CONNECTION_TYPE_ETHERNET Ethernet
    OTHER CONNECTION_TYPE_OTHER OTHER

    Data Collection and User Preferences

    By default, Conviva collects a set of data for better user analytics. However, the appropriate legal agreement with Conviva is required in order for Conviva to begin collecting data that would be considered PII, personal information, personal data or the like under applicable data privacy laws such as the General Data Protection Regulation (GDPR) and the California Consumer Privacy Act (CCPA). Further below in this document, there is a description of the user-preference APIs that control data collection, including opt-out and deletion of data, in compliance with data privacy laws. These APIs are in addition to existing, offline processes for opt-out and data deletion requests.

    This document describes the identifiers that the libraries are capable of collecting, however actual collection of identifiers is contingent upon the customer's legal department providing written instructions to Conviva to begin collection. At the discretion of the customer's legal department, some or all of these identifiers may be collected. Conviva provides this flexibility to allow the customer to determine the precise identifiers to be collected.

    Following tags are used to collect data:

    • Android OS
    • androidId: Android ID is unique to each application on a device and valid until factory reset. - gsfId: Google Service Framework ID which is provided by Play services framework. - gaId: Google Ad identifier provided by Google Play Service framework.
    • Fire OS
      • fireAdId: Amazon Ad identifier provided by Amazon FireOS.

    To retrieve the Google Service Framework ID, the following permission needs to be declared in the manifest.

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    

    Control the data collection

    public void setUserPreferenceForDataCollection (Map<String, Boolean> data);
    

    Set user preferences to opt-out of data collection by specifying the corresponding tag to true/false. By default, Conviva assumes no restriction in collecting data.

    where data is the Key/Value pair, where key indicates a probable data name and value is true/false. A value of true causes the SDK to allow collecting the data item and a value of false causes the SDK to stop collecting the data item.

    Map<String, Boolean> data = new HashMap<>();
    data.put("androidId", allowAndroidId); //allowAndroidId is true/false based on user preference.
    data.put("gsfId", allowGsfId);         // allowGsfId is true/false based on user preference.
    data.put("gaId",allowGaId);            // allowGaId is true/false based on user preference.
    ConvivaAnalytics.setUserPreferenceForDataCollection(data);
    

    Delete collected data

    public void setUserPreferenceForDataDeletion (Map<String, Boolean> data);
    

    Delete previously collected data and opt-out of data collection by specifying the corresponding tag. By default, Conviva assumes no deletion of data.

    where data is the Key/Value pair, where key indicates a probable data name and value is true/false. A value of true causes the SDK to delete and stop collecting that specific data item.

    Map<String, Boolean> data = new HashMap<>();
    data.put("androidId", deleteAndroidId);      // deleteAndroidId is true/false based on user preference.
    data.put("gsfId", deleteGsfId);              // deleteGsfId is true/false based on user preference.
    data.put("gaId",deleteGaId);                 // deleteGaId is true/false based on user preference.
    ConvivaAnalytics.setUserPreferenceForDataDeletion(data);
    

    Report Custom Events

    Player Insight is an advanced feature which allows you to track custom events that are not related to video rendering, but rather specific to your player's functionality. These events and their attributes are then tabulated in the Player Insight dashboard at Conviva VSI (Pulse). Contact your Conviva representative to enable Player Insights in Pulse.

    You may send a custom Player Insight event that can be associated with a video playback using the following method:

    Report video-related events by the method videoAnalytics.reportPlaybackEvent(String eventType, Map eventDetail)

    Report video-related events

    String eventType = "video_quality_change";
    
    // Sample code snippet illustrating event on explicit change of video quality in the player
    Map<String, Object> attr = new HashMap<>();
    attr.put("old_quality", "SD");
    attr.put("new_quality", "HD");
    attr.put("player", "WEB player");
    videoAnalytics.reportPlaybackEvent(eventType, attr);
    

    Report app-level events by the method ConvivaAnalytics.reportAppEvent(String eventType, Map eventDetail):

    Report app-level events

    // Syntax of the API to report the app-level  event
    void reportAppEvent(String eventType, Map<String, Object> eventDetail);
    
    // Sample for "share-click" event with 3 arguments
    String eventType = "share-click";
    Map<String, Object> attr = new HashMap<>();
    attr.put("location", "Toolbar");
    attr.put("assetName", "Sample Video");
    attr.put("shareService", "Facebook");
    ConvivaAnalytics.reportAppEvent(eventType, attr);
    

    Identifiers for Persistent Memory

    The following value is set on the player initialization. Any time this value is cleared during application handling, such viewer logout/logins and background/foreground changes, Conviva recommends storing the value in persistent memory. If this identifier is not kept persistence, the unique devices and active devices/users values may be inflated: sharedpreferences/conviva.xml.

    6. Clean Up Session

    After the player session ends, use report and release methods to end object reporting.

    At video playback end, call

    videoAnalytics.reportPlaybackEnded();
    

    For Ad content, call

    //Only applicable for custom ad integration, don't call for modules
    adAnalytics.reportAdEnded();
    

    On application exit, or when the Conviva object is destroyed, release the objects

    adAnalytics.release(); // if initialized
    videoAnalytics.release();
    ConvivaAnalytics.release();
    

    Advanced Use Cases

    You can use specific APIs in the Conviva sensor for various advanced use cases, such as:

    • Live or live linear streaming program changes
    • Video changes in the playlist
    • Playback does not recover from error and is reported once only
    • Multiple errors due to retry when playback does not recover
    • Playback recovers from a fatal error by switching to a different asset URL or CDN
    • Warning occurs when there's no impact on the playback
    • Handling user actions, such as user dialogues, backgrounding, and foregrounding

    To learn more about these advanced use cases, see here.

    Self Validation

    Upon completion of your integration, and before submission to Conviva QA team, developers should complete a comprehensive self-validation test pass of each Device Application.

    Perform self-validation of video sensor integration using Touchstone in Pulse.

    Conviva provides sample test cases with detailed steps and expected results.

    Developers should be checking for both metric and metadata accuracy. Based on our experience, comprehensive self-validation can reduce your QE cycles, saving your costly project time.