For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
StatusSupportDiscussionsLog inSign Up
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
Docs HomeAPI ReferenceVideo on DemandAI FeaturesLive StreamingVideo PlayerVideo DataCloud PlayoutRecipes
  • Player SDKs
    • Introduction
  • Web player
    • Install the FastPix web player
    • Play uploaded videos
    • Handle playback errors
  • Android player
    • Install FastPix Android player
    • Set up the player
    • Play uploaded videos
    • Handle playback errors
      • Complete integration example
  • iOS player
    • Install FastPix iOS player
    • Play uploaded videos
    • Handle playback errors
  • Flutter player
    • Install FastPix Flutter player
    • Play uploaded videos
    • Handle playback errors
LogoLogo
StatusSupportDiscussionsLog inSign Up
On this page
  • Full Activity setup
  • Key points
Android playerExamples

Complete integration example

Was this page helpful?
Previous

Install FastPix iOS player

Next
Built with

A full example showing how to set up the FastPix Android Player with playback, seek preview, resolution control, and analytics.

Full Activity setup

This example demonstrates a complete Activity with player initialization, listener registration, seek preview, analytics, resolution control, custom domain, and resource cleanup:

1import io.fastpix.media3.PlayerView
2import io.fastpix.media3.PlaybackListener
3import io.fastpix.media3.analytics.AnalyticsConfig
4import io.fastpix.media3.core.FastPixPlayer
5import io.fastpix.media3.core.PlaybackResolution
6import io.fastpix.media3.core.RenditionOrder
7import io.fastpix.media3.seekpreview.models.PreviewFallbackMode
8import io.fastpix.media3.seekpreview.models.SeekPreviewConfig
9import io.fastpix.data.domain.model.VideoDataDetails
10import androidx.media3.common.PlaybackException
11
12class CustomizedPlayerActivity : AppCompatActivity() {
13 private lateinit var binding: ActivityCustomizedPlayerBinding
14 private val playerView get() = binding.playerView
15 private var player: FastPixPlayer? = null
16 private lateinit var playbackListener: PlaybackListener
17
18 override fun onCreate(savedInstanceState: Bundle?) {
19 super.onCreate(savedInstanceState)
20 binding = ActivityCustomizedPlayerBinding.inflate(layoutInflater)
21 setContentView(binding.root)
22
23 // Configure seek preview
24 val seekPreviewConfig = SeekPreviewConfig.Builder()
25 .setEnabled(true)
26 .setFallbackMode(PreviewFallbackMode.TIMESTAMP)
27 .setEnablePreload(true)
28 .setPreloadRadius(1)
29 .setCacheEnabled(true)
30 .build()
31
32 // Configure analytics
33 val analyticsConfig = AnalyticsConfig.Builder(playerView, "YOUR_WORKSPACE_ID")
34 .setVideoDataDetails(VideoDataDetails(videoId = "videoId", videoTitle = "videoTitle"))
35 .setEnabled(true)
36 .build()
37
38 // Build the player
39 player = FastPixPlayer.Builder(this)
40 .setAutoplay(true)
41 .setLoop(false)
42 .setSeekPreviewConfig(seekPreviewConfig)
43 .setAnalyticsConfig(analyticsConfig)
44 .build()
45 playerView.player = player
46 }
47
48 override fun onStart() {
49 super.onStart()
50 startPlayback()
51 }
52
53 private fun startPlayback() {
54 // Set up the playback listener
55 playbackListener = object : PlaybackListener {
56 override fun onPlay() {}
57 override fun onPause() {}
58 override fun onPlaybackStateChanged(isPlaying: Boolean) {}
59 override fun onError(error: PlaybackException) {}
60 }
61 player?.addPlaybackListener(playbackListener)
62
63 // Configure and start playback
64 val ok = player?.setFastPixMediaItem {
65 playbackId = "YOUR_PLAYBACK_ID"
66 minResolution = PlaybackResolution.LD_480
67 maxResolution = PlaybackResolution.FHD_1080
68 renditionOrder = RenditionOrder.Descending
69 playbackToken = "SET_PLAYBACK_TOKEN"
70 customDomain = "SET_CUSTOM_DOMAIN"
71 } ?: false
72 if (!ok) return
73 }
74
75 override fun onStop() { super.onStop() }
76 override fun onPause() { super.onPause() }
77
78 override fun onDestroy() {
79 super.onDestroy()
80 player?.removePlaybackListener(playbackListener)
81 if (isFinishing) {
82 playerView.release()
83 }
84 }
85}

Key points

  • Uses view binding (ActivityCustomizedPlayerBinding) to access PlayerView from the layout.
  • A FastPixPlayer instance is created once and attached to PlayerView.
  • A PlaybackListener observes playback state and errors.
  • setFastPixMediaItem { ... } generates the playback URL using playbackId plus optional parameters.
  • Seek preview and analytics are configured through the builder.
  • Call playerView.release() in onDestroy() when the Activity is finishing to release resources.

Replace the placeholder values with your actual workspace ID, playback ID, token, and custom domain.