OwnVideoPlayer is a powerful and extremely simple library for playing videos on Android using Media3. It is designed to be "plug & play", automatically managing state, media notifications, and the user interface.
- ✅ Extreme Simplicity: Play videos with just one line of code.
- ✅ Automatic Management: The library internally handles the ViewModel and the player lifecycle.
- ✅ Smart Notifications: Automatically generates titles and thumbnails (frame capture) for the system media notification.
- ✅ True FullScreen Mode: Supports expansion to a full-screen dialog, hiding system bars.
- ✅ Multi-Source Support: Play from URL or local resources (Raw).
Add JitPack to your settings.gradle.kts file:
dependencyResolutionManagement {
repositories {
maven { url = uri("https://jitpack.io") }
}
}Add the dependency to your build.gradle.kts:
dependencies {
implementation("com.github.Danwolve98:OwnVideoPlayer:1.0")
}For media notifications to work correctly, add the permissions and service to your AndroidManifest.xml:
<!-- Required Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />Ideal for embedding the video within a screen (e.g., a feed or a header). It manages its own state.
OwnVideoPlayer(
source = VideoSource.Url("https://yoursite.com/video.mp4"),
modifier = Modifier.fillMaxWidth().height(250.dp),
repeatMode = true // The video will loop automatically
)Shows the video in a dialog that automatically occupies the entire screen.
var showDialog by remember { mutableStateOf(false) }
OwnVideoPlayerDialog(
show = showDialog,
source = VideoSource.Raw(R.raw.my_local_video),
onDismiss = { showDialog = false }
)The library automatically extracts the filename and a thumbnail from the video, but you can customize it:
val info = NotificationInfo(
title = "My Movie",
artist = "Famous Director",
photoUrl = "https://image.com/poster.jpg" // Optional: if null, it captures a video frame
)
OwnVideoPlayer(
source = VideoSource.Url(url),
notificationInfo = info
)| Parameter | Type | Description |
|---|---|---|
source |
VideoSource |
Url(String) or Raw(Int). |
showControls |
Boolean |
(Only in OwnVideoPlayer) Whether to show buttons and the progress bar. |
repeatMode |
Boolean |
Whether the video should automatically restart when finished. |
fullScreenMode |
FullScreenMode |
SYSTEM_UI (integrated) or DIALOG (expands to full screen). |
notificationInfo |
NotificationInfo |
Data for the media notification (Title, Artist, Image). |
OwnVideoPlayer is under the MIT license. See the LICENSE.txt file for more information.