Listen to playback events
Learn how to observe playback state changes, buffering, seek events, and more using the PlaybackListener interface.
All callbacks are invoked on the main thread.
Attach a playback listener
Callback details
onPlayerReady(durationMs)fires once per media item when the player reaches READY for the first time, not on every rebuffer or seek.onTimeUpdate(...)fires periodically during active playback (default ~500ms) and stops automatically when paused, ended, or when no listeners remain.onSeekStart/onSeekEndtrigger for both user scrubs and programmaticseekTocalls.onBufferingStart/onBufferingEndfire on buffering transitions. Use these to show or hide a loading spinner.onCompleted()fires when reaching the end of media. Ifloop = true, this callback still fires before the video repeats.onFirstFrameRendered()fires when the first video frame is on screen. Use it to hide a poster or placeholder image.
For video quality changes, the onVideoQualityChanged(quality, source) callback is covered in Switch video quality.
Remove the listener
Remove the listener when it’s no longer needed to avoid leaks:
Frequently asked questions
What playback events can I listen to in the FastPix Android player?
The PlaybackListener interface delivers onPlay, onPause, onPlaybackStateChanged, onPlayerReady, onTimeUpdate, onSeekStart, onSeekEnd, onBufferingStart, onBufferingEnd, onFirstFrameRendered, onVolumeChanged, onMuteStateChanged, onPlaybackRateChanged, onCompleted, and onError.
How do I detect buffering?
Implement onBufferingStart and onBufferingEnd. They fire on buffering transitions, so use them to show a loading spinner when buffering begins and hide it when playback resumes.
How do I know when playback finished?
The onCompleted callback fires when playback reaches the end of the media. It still fires even when loop = true, called just before the video repeats.
On which thread are the callbacks invoked?
All PlaybackListener callbacks are invoked on the main thread, so you can update your UI directly from inside them without switching threads.
What’s next
- Handle playback errors to respond to the
onErrorcallback. - Switch video quality for the
onVideoQualityChangedcallback. - Control video playback for play, pause, and seek control.