The Kotlin Camera2 API Video Exoplayer Android development tutorial describes how to playback the recorded video using ExoPlayer in its own Android Fragment.
The Android Uri for the ExoPlayer will be passed via the Android ViewModel.
For further examples of using the Android ExoPlayer checkout this Kotlin on Android tutorial.
This Kotlin on Android tutorial follows on the Andriod ViewModel episode.
In this Kotlin on Android tutorial we will cover:
- Installing the ExoPlayer library
- Creating a SimpleExoPlayer instance
- Creating a MediaSource
- Hiding the ExoPlayer controllers
- Setting the SimpleExoPlayer to the PlayerView
- Preparing the ExoPlayer
- Setting the ExoPlayer for auto play
- Stopping & releasing the ExoPlayer
Episodes
- Icons
- MediaRecorder
- Rear Camera Record
- Round preview thumbnail
- Sharing Uri with ViewModel
- Video Playback with ExoPlayer
- Video PIP
- Front Camera Record (Premium)
- Video Record with Audio (Premium)
- Replace TextureView with SurfaceView (Premium)
Disclaimer, it is recommended to follow this Kotlin on Android tutorial series using a Google Pixel or Nexus device.
Please do not try it with the Android Emulator. Bugs have also been observed in camera stacks of none Google devices, which may be exposed by this tutorial series.
Conclusion
This Kotlin camera2 API video Exoplayer Android development tutorial described how to install and add the ExoPlayer to an Android fragment.
Kotlin lazy delegates were used for creating the Android SimpleExoPlayer and MediaSource instances.
The Android ViewModel was used to get the video Uri, which was required for the MediaSource creation.
The ExoPlayer was set up to work with the Android fragment lifecycle states when starting or stopping.
The following Kotlin tutorial will describe how to implement video Picture in Picture (PIP) mode for during video playback.