CustomExoPlayer is a customizable Android library built on top of ExoPlayer from Media3 API, providing additional features and functionalities to enhance media playback in your Android applications using Jetpack Compose.
- Custom UI Components: Tailor the look and feel of the ExoPlayer UI according to your app's design.
- Advanced Playback Controls: Implement custom volume controls for a seamless user experience.
- Show playback progress: Show playback progress to users in center circular progress and in bottom slider.
- Play video from mp4 link: Play .mp4 media items from their URL.
- Play video from last paused position: Tailored to start playing the video from last paused position
To integrate ExoPlayer into your Android project, follow these steps:
-
Add the library to your project dependencies:
implementation("androidx.media3:media3-exoplayer:1.2.1") implementation("androidx.media3:media3-ui:1.2.1") implementation("androidx.media3:media3-exoplayer-dash:1.2.1")implementation 'com.github.PriyaSindkar:CustomExoPlayer:1.0.0'
-
Use just one call to build an entire customizable player
VideoPlayer(
context = LocalContext.current,
modifier = Modifier
.fillMaxSize(),
videoUrl = videoPlayerUiState.extractedVideoUrl,
lastPaused = lastPaused,
returnToHomeScreen = returnToHomeScreen, // go back
showSurvey = showSurvey
)
- Build media item from URL
val mediaItem = remember(videoUrl) {
MediaItem.Builder()
.setUri(videoUrl)
.setMimeType(MimeTypes.APPLICATION_MP4)
.build()
}
val player = remember(context) {
ExoPlayer.Builder(context)
.build()
}.apply {
setMediaItem(mediaItem)
prepare()
playWhenReady = true
}
- Manage orientation changes while playing the video