Enable fullscreen mode

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

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:

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

Enable tap gesture

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

1playerView.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:

1override fun onDestroy() {
2 super.onDestroy()
3 player?.removePlaybackListener(playbackListener)
4 if (isFinishing) {
5 playerView.release()
6 }
7}