Monitor Brightcove Player (Android)

Understand how to integrate the FastPix Data SDK with Brightcove Player to track playback and QoE metrics.

This FastPix Data SDK integration for Brightcove Player helps you track key video metrics like user interactions, playback quality, and performance to enhance the viewing experience. It lets you customize data tracking, monitor streaming quality, and securely send insights for better optimization and error resolution. The integration enables comprehensive video performance tracking and user engagement metrics with minimal setup required.


Key features:

  • Seamless integration with Brightcove Player events
  • Automatic beacon domain selection for staging and production environments
  • Simple configuration objects for quick setup
  • Automatic cleanup of analytics resources
  • Capture detailed viewer interaction data
  • Monitor playback quality and streaming diagnostics
  • Robust error reporting and diagnostics


Prerequisites

  1. An existing Android Studio project where you plan to integrate the FastPix Data SDK
  2. Gradle configured in your project for managing dependencies
  3. GitHub Personal Access Token (PAT) from your GitHub account for SDK access.
  4. To track and analyze video performance, initialize the SDK with your Workspace key. Learn about Workspaces.
    • Access the FastPix Dashboard: Log in and navigate to the Workspaces section.
    • Locate Your Workspace Key: Copy the Workspace Key for client-side monitoring.

Getting started with FastPix:

To track and analyze video performance, initialize the FastPix Data SDK with your Workspace key:

  1. Access the FastPix Dashboard: Log in and navigate to the Workspaces section.
  2. Locate Your Workspace Key: Copy the Workspace Key for client-side monitoring. Included in your Android application's code wherever you want to track video performance and analytics.

Step 1: Install and setup:

Add our maven repository to your settings.gradle:

repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
        maven {
            url =uri("https://repo.brightcove.com/releases")
        }
         maven {
            url = uri("https://maven.pkg.github.com/FastPix/android-data-exo-player-sdk")
            credentials {
                // Your GitHub account username (or) FastPix
                username = "your-github-username"
                // Your (PAT) Personal access token Get It from you Github account
                password = "your-personal-access-token"
            }
        }
    }

Add the FastPix Data Core SDK dependencie to your build.gradle:

dependencies {
    //check for the latest version
    implementation("io.fastpix.data:exoplayer:1.1.0")
    implementation("com.brightcove.player:exoplayer2:9.2.3")
}

  1. Sync your project with Gradle files

Click "Sync Now" in the notification bar to download and integrate the FastPix Data SDK.

Once the above dependency is added, you can use the FastPix Data SDK module into your Android project where you intend to use its functionalities.


Beacon URL Configuration

The beaconUrl parameter specifies which FastPix analytics environment receives your video performance data. Use the appropriate beacon domain based on your deployment environment


Usage

Make sure Brightcove Player is installed and integrated with your project as part of the FastPix data setup. You can initialize Brightcove with a PlayerView in your Android application to enable seamless functionality.


Step 2: Import the SDK

 import io.fastpix.exoplayer_data_sdk.FastPixBaseExoPlayer

Step 3: Basic Integration

Brightcove's SDK for Android encapsulates an underlying ExoPlayer instance. To integrate, extract the ExoPlayer and create an instance of FastPixBaseExoPlayer for monitoring

   
// MainActivity.kt 

import android.content.pm.ActivityInfo
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.brightcove.player.display.ExoPlayerVideoDisplayComponent
import com.brightcove.player.event.Event
import com.brightcove.player.event.EventListener
import com.brightcove.player.event.EventType
import com.brightcove.player.model.DeliveryType
import com.brightcove.player.model.Video
import com.example.media3muxdata.databinding.ActivityMainBinding
import com.google.android.exoplayer2.ExoPlayer
import io.fastpix.data.domain.model.CustomDataDetails
import io.fastpix.data.domain.model.PlayerDataDetails
import io.fastpix.data.domain.model.VideoDataDetails
import io.fastpix.exoplayer_data_sdk.FastPixBaseExoPlayer
import java.util.UUID

class MainActivity : BrightcovePlayer(), EventListener { 

private lateinit var binding: ActivityMainBinding 
private lateinit var fastPixDataSDK: FastPixBaseExoPlayer 
private lateinit var exoPlayer: ExoPlayer 

override fun onCreate(savedInstanceState: Bundle?) { 
// Set up the layout and view binding 
   binding = ActivityMainBinding.inflate(layoutInflater) 
   setContentView(binding.root) 
    
   // Call superclass constructor for lifecycle management 
   super.onCreate(savedInstanceState) 
    
   // Create and configure the video for playback 
   val video = Video.createVideo( 
       “your-stream-url”, 
       DeliveryType.HLS 
   ) 
    
   // Add the video to the player view and start playback 
   binding.playerView.add(video) 
   binding.playerView.start() 
    
   // Register event listeners for fullscreen transitions 
   val emitter = binding.playerView.eventEmitter 
   emitter.on(EventType.ENTER_FULL_SCREEN, this) 
   emitter.on(EventType.EXIT_FULL_SCREEN, this) 
    
   // Extract the ExoPlayer instance from Brightcove's video display component 
   val videoDisplayComponent =  
       binding.playerView.videoDisplay as ExoPlayerVideoDisplayComponent 
   exoPlayer = videoDisplayComponent.exoPlayer 
    
   // Configure video metadata for analytics tracking 
   val videoDataDetails = VideoDataDetails( 
       UUID.randomUUID().toString(),  // Unique video identifier 
       "Video Title"                   // Video display name 
   ).apply { 
       videoSeries = "Series Name" 
       videoProducer = "Producer Name" 
       videoContentType = "Content Type" 
       videoVariant = "Variant Info" 
       videoLanguage = "en" 
   } 
    
   // Configure custom dimensions for business-specific tracking 
   val customDataDetails = CustomDataDetails() 
   customDataDetails.customField1 = "Custom Value 1" 
   customDataDetails.customField2 = "Custom Value 2" 
    
   // Define player metadata for version tracking 
   val playerDataDetails = PlayerDataDetails( 
       playerName = "brightcove_player", 
       playerVersion = "9.2.3" 
   ) 
    
   // Initialize FastPix Data SDK for analytics collection 
   fastPixDataSDK = FastPixBaseExoPlayer( 
       this, 
       playerView = binding.playerView, 
       exoPlayer = exoPlayer, 
       workSpaceId = "YOUR_WORKSPACE_ID", 
       videoDataDetails = videoDataDetails, 
       playerDataDetails = playerDataDetails, 
       enableLogging = true, 
       customDataDetails = customDataDetails 
   ) 
} 

override fun processEvent(p0: Event) { 
   when (p0?.type) { 
       EventType.ENTER_FULL_SCREEN -> { 
           requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE 
       } 
       EventType.EXIT_FULL_SCREEN -> { 
           requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT 
       } 
   } 
} 

override fun onDestroy() { 
   super.onDestroy() 
   fastPixDataSDK.release() 
   binding.playerView.clear() 
} 
 

}