> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Monitor ExoPlayer

The FastPix Data SDK with [ExoPlayer](https://github.com/FastPix/android-data-exoplayer-sdk) 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.

**Key features:**

* Capture user engagement through detailed viewer interaction data.
* Monitor playback quality with real-time performance analysis.
* Identify and fix video delivery bottlenecks on Android.
* Customize tracking to match specific monitoring needs.
* Handle errors with robust reporting and diagnostics.
* Gain deep insights into video performance with streaming diagnostics.

\


#### [Step 1](/video-data/monitors/exoplayer#step-1-install-and-setup)

Install and setup

#### [Step 2](/video-data/monitors/exoplayer#step-2-import)

Import the SDK

#### [Step 3](/video-data/monitors/exoplayer#step-3-basic-integration)

Basic integration

#### [Step 4](/video-data/monitors/exoplayer#step-4-including-custom-data-and-metadata)

Add metadata

#### [Step 5](/video-data/monitors/exoplayer#step-5-advanced-customization-with-fastpix-data-sdk)

Advanced Customization

#### [Step 6](/video-data/monitors/exoplayer#step-6-emit-custom-events)

Emit custom events

#### [Detailed example](/video-data/monitors/exoplayer#example-to-configure-exoplayer-with-fastpix-data-sdk)

Configure ExoPlayer

* [Step 1](/video-data/monitors/exoplayer#step-1-install-and-setup)

Install and setup

* [Step 2](/video-data/monitors/exoplayer#step-2-import)

Import the SDK

* [Step 3](/video-data/monitors/exoplayer#step-3-basic-integration)

Basic integration

* [Step 4](/video-data/monitors/exoplayer#step-4-including-custom-data-and-metadata)

Add metadata

* [Step 5](/video-data/monitors/exoplayer#step-5-advanced-customization-with-fastpix-data-sdk)

Advanced Customization

* [Step 6](/video-data/monitors/exoplayer#step-6-emit-custom-events)

Emit custom events

* [Detailed example](/video-data/monitors/exoplayer#example-to-configure-exoplayer-with-fastpix-data-sdk)

Configure ExoPlayer

\


## Prerequisites

1. To track and analyze video performance, initialize the FastPix Data SDK with your [Workspace key](/getting-started/set-up-a-workspace#workspaces). This key is essential for client-side monitoring and must be included in your Android application's code wherever you want to track video performance.
2. An existing Android Studio project where you plan to integrate the FastPix Data SDK.
3. Gradle configured in your project for managing dependencies.
4. ExoPlayer pre-installed and integrated with your project for FastPix data setup.

\


## Step 1: Install and setup

1. **Open your Android Studio project** where you want to integrate the SDK.
2. **Add the FastPix Data SDK dependency:**

   Navigate to your app-level **build.gradle** file (or build.gradle.kts if using Kotlin DSL).

   \


   ```groovy
   //Add the following line under the dependencies section: 
   dependencies{ 
     
   	// check with latest version 
     implementation 'io.fastpix.data:exoplayer:1.1.0 ' 
   } 
   ```

   \


   Navigate to your **settings.gradle** file

   \


   ```groovy
   //Add the following lines inside repositories section: 
   repositories { 
     maven { 
     url = uri("https://maven.pkg.github.com/FastPix/android-data-exo-player-sdk")  
     credentials { 

     // Your GitHub account username (or) FastPix  
     username = "github-user-name" 

     // Your (PAT) Personal access token Get It from you Github account 
     password = "github-pat"   
      	      } 
     	} 
   } 
   ```

\


3. **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.

\


> **PLEASE NOTE**\
> To ensure accurate analytics, initialize and complete the ExoPlayer setup first. Once the player is fully ready, integrate and start the Android data analytics SDK in your project.

\


## Step 2: Import the SDK

```kotlin
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
```

\


## Step 3: Basic integration

\


### Globally declare

You need to globally declare the **ExoPlayer** instance and **FastPixBaseExoPlayer** in your Android application. A global declaration ensures that these objects can be accessed throughout the lifecycle of your activity or application where required.

\


```java
import ... 

class VideoPlayerActivity : AppCompatActivity() { 
    private lateinit var exoPlayer: ExoPlayer // Global ExoPlayer instance 
    private lateinit var fastPixDataSDK: FastPixBaseExoPlayer 
} 
```

\


You can initialize ExoPlayer with a `PlayerView` or `SurfaceView` in your Android application to enable seamless functionality. Use the following Kotlin or Java code in your Android application to configure ExoPlayer with FastPix:

\


```kotlin
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

class VideoPlayerActivity : AppCompatActivity() { 

    private lateinit var exoPlayer: ExoPlayer 
    private lateinit var fastPixDataSDK: FastPixBaseExoPlayer
  
    override fun onCreate(savedInstanceState: Bundle?) { 
        super.onCreate(savedInstanceState) 
		setContentView(R.layout.your_layout) // don't forget this if needed 
        initializePlayers() 
    } 

    private fun initializePlayers() { 
        // Initialize ExoPlayer 
        exoPlayer = ExoPlayer.Builder(this).build() 
        val mediaItem = MediaItem.fromUri("https://your.video.url/here.mp4") 
        exoPlayer.setMediaItem(mediaItem) 
        exoPlayer.prepare()

		val playerDataDetails = PlayerDataDetails(
            "player-name",
            "player-version"
        )
        val videoDataDetails =
            VideoDataDetails(
                UUID.randomUUID().toString(),
                videoModel?.id
            ).apply {
                videoSeries = "This is video series"
                videoProducer = "This is video Producer"
                videoContentType = "This is video Content Type"
                videoVariant = "This is video Variant"
                videoLanguage = "This is video Language"
				// ...etc
            }
        val customDataDetails = CustomDataDetails().apply {
			customField1 = "Custom 1",
			customField2 = "Custom 2"
			// ... etc
			customField10 = "Custom 3"
		}
		
        fastPixDataSDK = FastPixBaseExoPlayer(
            this,
            playerView = binding.playerView,
            exoPlayer = exoPlayer,
            workSpaceId = "workspace-id",
            videoDataDetails = videoDataDetails,
            playerDataDetails = playerDataDetails,
            customDataDetails = customDataDetails
        )
    } 
} 
```

```java
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

public class VideoPlayerActivity extends AppCompatActivity { 
  
    private ExoPlayer exoPlayer; 
    private FastPixBaseExoPlayer fastPixDataSDK; 
  
    // You’ll need to define this or use ViewBinding 
    private PlayerView playerView;  

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
		super.onCreate(savedInstanceState); 
		setContentView(R.layout.your_layout);
        initializePlayers(); 
    } 
  
    private void initializePlayers() { 

        // 1. Initialize ExoPlayer 
        exoPlayer = new ExoPlayer.Builder(this).build(); 
        MediaItem mediaItem = MediaItem.fromUri("https://your.video.url/here.mp4"); 
        exoPlayer.setMediaItem(mediaItem); 
        exoPlayer.prepare(); 

		// Optional
        final VideoDataDetails videoDataDetails = new VideoDataDetails("video-id", "video-title");
		videoDataDetails.videoSeries = "video-series";
		videoDataDetails.videoProducer = "video-producer";
		videoDataDetails.videoContentType = "video-content-type";
		videoDataDetails.videoVariant = "video-variant";
		videoDataDetails.videoLanguage = "video-language";
		videoDataDetails.videoDuration = "video-duration";
		// ... etc

		// Optional
		final CustomDataDetails customDataDetails = new CustomDataDetails();
		customDataDetails.customField1 = "Custom 1";
		customDataDetails.customField2 = "Custom 2";
		// ... etc
		customDataDetails.customField2 = "Custom 3";

		// Optional
		final PlayerDataDetails playerDataDetails = new PlayerDataDetails();
		playerDataDetails.playerName = "exo-player";
		playerDataDetails.playerVersion = "latest-version"

		fastPixDataSDK = new FastPixBaseExoPlayer(
			this,
			playerView,
			exoPlayer,
			"workspace-id",
			playerDataDetails,
			videoDataDetails,
			customDataDetails
		);
    } 
} 
```

\


## Step 4: Including custom data and metadata

* `workSpaceId` is a mandatory parameter that tells the SDK on which workspace the data will collect.
* `playerView` is another mandatory parameter.
* `exoPlayer` is also a mandatory parameter that SDK uses to anylyze the playback.

Check out the [user-passable metadata](/video-data/use-custom-dimensions)  documentation to see the metadata supported by FastPix. You can use custom metadata fields like custom\_1 to custom\_10 for your business logic, giving you the flexibility to pass any required values. Named attributes, such as video\_title and video\_id, can be passed directly as they are.

\


```kotlin
override fun onCreate(savedInstanceState: Bundle?) { 
	 val videoDataDetails = VideoDataDetails("video-id", "video-title").apply {
            videoSeries = "video-series"
            videoProducer = "video-producer"
            videoContentType = "video-content-type"
            videoVariant = "video-variant"
            videoLanguage = "video-language"
            videoDuration = "video-duration"
            //...etc
        }
        val customDataDetails = CustomDataDetails().apply {
            customField1 = "Custom 1"
            customField2 = "Custom 2"
            //...etc
        }
        // By Default player sets these things, You don't have to worry about it unless you're not using
        // some wrapper around media3
        val playerDataDetails = PlayerDataDetails(
            playerName = "media3",
            playerVersion = "latest-version"
        )
		fastPixDataSDK = FastPixBaseExoPlayer(
            this, // context
            playerView = binding.playerView, // media3 playerView from XML
            exoPlayer = exoPlayer, // media3 player
            beaconUrl = "your-domain.com", // custom domain (Optional)
            workSpaceId = "workspace-id",
            playerDataDetails = playerDataDetails, // Optional
            videoDataDetails = videoDataDetails, // Optional
            customDataDetails = customDataDetails // Optional
        )
} 
```

\


To set up video analytics, create a FastPixBaseExoPlayer object by providing the following parameters: your application's Context (usually the Activity), the ExoPlayer instance, and the `customerDataEntity` and `customOptions` objects that you have prepared.

```kotlin
fastPixDataSDK = FastPixBaseExoPlayer(
            this, // context
            playerView = binding.playerView, // media3 playerView from XML
            exoPlayer = exoPlayer, // media3 player
            workSpaceId = "workspace-id",
)
```

\


Finally, when destroying the player, make sure to call the `FastPixBaseExoPlayer.release()` function to properly release resources.

```kotlin
override fun onDestroy() { 
  	super.onDestroy() 
	fastPixDataSDK.release() // Cleanup FastPix tracking 
} 
```

\


After completing the integration, start playing a video in your player. A few minutes after stopping playback, you’ll see the results in your FastPix Video Data dashboard. Log in to the dashboard, navigate to the workspace associated with your `ws_key`, and look for video views.

\


## Example to configure ExoPlayer with FastPix Data SDK.

Here are platform-specific examples to help you integrate the FastPix Data SDK with your ExoPlayer. Use the following Kotlin or Java code into your application:

\


```kotlin
import io.fastpix.data.domain.model.CustomDataDetails
import io.fastpix.data.domain.model.PlayerDataDetails
import io.fastpix.data.domain.model.VideoDataDetails
import io.fastpix.data.exo.FastPixBaseExoPlayer
 
class VideoPlayerActivity : AppCompatActivity() { 
 
    private lateinit var exoPlayer: ExoPlayer 
    private var fastPixDataSDK: FastPixBaseExoPlayer? = null
    override fun onCreate(savedInstanceState: Bundle?) { 
        super.onCreate(savedInstanceState) 
        setContentView(R.layout.your_layout)
        initializePlayers() 
    } 

    private fun initializePlayers() { 

        // Initialize ExoPlayer 
        exoPlayer = ExoPlayer.Builder(this).build() 
        val mediaItem = MediaItem.fromUri("https://your.video.url/here.mp4") 
        exoPlayer.setMediaItem(mediaItem) 
        exoPlayer.prepare() 

        val videoDataDetails = VideoDataDetails("video-id", "video-title").apply {
            videoSeries = "video-series"
            videoProducer = "video-producer"
            videoContentType = "video-content-type"
            videoVariant = "video-variant"
            videoLanguage = "video-language"
            videoDuration = "video-duration"
            //...etc
        }
		val customDataDetails = CustomDataDetails().apply {
            customField1 = "Custom 1"
            customField2 = "Custom 2"
            //...etc
        }
		
		// By Default player sets these things, You don't have to worry about it unless you're not using
        // some wrapper around media3
        val playerDataDetails = PlayerDataDetails(
            playerName = "media3",
            playerVersion = "latest-version"
        )

		fastPixDataSDK = FastPixBaseExoPlayer(
            this, // context
            playerView = binding.playerView, // media3 playerView from XML
            exoPlayer = exoPlayer, // media3 player
            workSpaceId = "workspace-id",
            playerDataDetails = playerDataDetails,
            videoDataDetails = videoDataDetails,
            customDataDetails = customDataDetails
        )
    } 
    override fun onDestroy() { 
        super.onDestroy() 
        fastPixDataSDK.release()
    } 
} 
```

```java
import io.fastpix.data.domain.model.CustomDataDetails
import io.fastpix.data.domain.model.PlayerDataDetails
import io.fastpix.data.domain.model.VideoDataDetails
import io.fastpix.data.exo.FastPixBaseExoPlayer
  
public class VideoPlayerActivity extends AppCompatActivity {  
    private ExoPlayer exoPlayer; 
    private FastPixBaseExoPlayer fastPixDataSDK;

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.your_layout);
        initializePlayers(); 
    } 

    private void initializePlayers() { 
      VideoDataDetails videoDataDetails = new VideoDataDetails("video-id", "video-title");
       	videoDataDetails.setVideoSeries("video-series");
		videoDataDetails.setVideoProducer("video-producer");
		videoDataDetails.setVideoContentType("video-content-type");
		videoDataDetails.setVideoVariant("video-variant");
		videoDataDetails.setVideoLanguage("video-language");
		videoDataDetails.setVideoDuration("video-duration");
		// ... etc

		CustomDataDetails customDataDetails = new CustomDataDetails();
		customDataDetails.setCustomField1("Custom 1");
		customDataDetails.setCustomField2("Custom 2");
		// ... etc

		// By default player sets these things, you don't have to worry about it
		// unless you're using some wrapper around Media3
		PlayerDataDetails playerDataDetails = new PlayerDataDetails(
		        "exo-player",             // playerName
		        "latest-version"      // playerVersion
		);

		fastPixDataSDK = new FastPixBaseExoPlayer(
		        this,                       // context
		        binding.getPlayerView(),    // media3 PlayerView from XML
		        exoPlayer,                  // media3 player instance
		        "beacon-url",               // beaconUrl (Optional)
		        "workspace-id",             // workSpaceId
		        playerDataDetails,          // player data (Optional)
		        videoDataDetails,           // video data (Optional)
		        customDataDetails           // custom data (Optional)
		);
    } 

    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
        if (fastPixDataSDK != null) { 
            fastPixDataSDK.release(); // Cleanup FastPix tracking
			fastPixDataSDK = null;
        } 
    } 
} 
```

\


---

\


## Release notes

For a complete release history, including new features, improvements, and bug fixes, see the [FastPix Exoplayer SDK CHANGELOG on GitHub](https://github.com/FastPix/android-data-exoplayer-sdk/blob/main/CHANGELOG.md).