Skip to navigation

Enable fullscreen mode

Learn how to handle configuration changes and player retention for fullscreen playback in the FastPix Android Player.

How fullscreen works

Fullscreen is developer-controlled, not automatic. When the player enters fullscreen, PlayerView detaches from its original parent, attaches to the Activity’s root decor view, and hides the system UI (the status bar and navigation bar). Playback state and listeners are preserved throughout.

When the player exits fullscreen, the view returns to its original parent, the system UI is restored, and playback continues seamlessly. A few behaviors worth knowing:

  • Fullscreen supports both portrait and landscape, and it does not force orientation changes. It handles orientation changes that happen while in fullscreen.
  • Fullscreen state is cleaned up automatically if the view is detached, so a view that leaves the window never leaves the player stuck in fullscreen.

Handle configuration changes

By default, PlayerView retains the player instance across configuration changes (such as device rotation). This is controlled by the retainPlayerOnConfigChange property, which defaults to true.

For this to work correctly, assign an android:id to your PlayerView in the XML layout. Without an ID, the view can’t retain or recover the player instance across rotation:

<io.fastpix.media3.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Enable tap gesture

Enable single-tap to toggle play/pause, which is useful for fullscreen player UIs:

playerView.isTapGestureEnabled = true

This uses togglePlayPause() internally.

Release the player

Call playerView.release() in onDestroy when the Activity is finishing to force a release even if retention is enabled:

override fun onDestroy() {
super.onDestroy()
player?.removePlaybackListener(playbackListener)
if (isFinishing) {
playerView.release()
}
}