dsa28s / compose-video Goto Github PK
View Code? Open in Web Editor NEWVideo UI Component for Jetpack Compose (Powered by androidx.media3)
Home Page: https://dsa28s.github.io/compose-video/
License: Apache License 2.0
Video UI Component for Jetpack Compose (Powered by androidx.media3)
Home Page: https://dsa28s.github.io/compose-video/
License: Apache License 2.0
Hello,
i have a problem,
actually i tried samsung j8, s23 or xiaomi devices and video normal on these devices but i tried galaxy a series (a73 and a34) and this problem occurred,
the problem is i select a video and video overflow, when once i tap the screen and the video size returns to normal?
What can i do?
Hi! Nice extension.
I was experimenting with it and found that when using m3u8 network playback stream, the handleLifecycle=true paused playback properly when leaving the app, but never resumed it when coming back, resulting in back screen.
Not sure if it is a bug or a problem on my end. Perhaps it makes sense to be able to optionally create the exoplayer instance outside the library, for having more control over the instance? I'd assume then I would be able to use it to control playback with some custom logic.
is there any way to hide video player back overlay before loading media item? (im using network media item)
preferably passed in by the user instead of hardcoding “currentActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT”
I want to know how to play multi-exoplayer like this picture
[explain]
fun MultiPlayerScreen(){
Column(){
VideoScreen() // 1
videoScreen() //2
}
}
-----------------------------------------------------------------------------------------------------------------------------------
const val MIME_TYPE_DASH = MimeTypes.APPLICATION_MPD
const val MIME_TYPE_HLS = MimeTypes.APPLICATION_M3U8
const val MIME_TYPE_VIDEO_MP4 = MimeTypes.VIDEO_MP4
@Composable
fun VideoScreen(
onChangeView : () -> Unit,
durationTime : Long = 8000L,
){
val currentChangeView by rememberUpdatedState(newValue = onChangeView)
var repeatMode by remember { mutableStateOf(RepeatMode.ALL) }
val context = LocalContext.current
LaunchedEffect(Unit){
delay(durationTime)
if(durationTime != 0L) currentChangeView()
}
VideoPlayer(
mediaItems = listOf(
VideoPlayerMediaItem.NetworkMediaItem(
url = "https://html5demos.com/assets/dizzy.mp4",
mediaMetadata = MediaMetadata.Builder().setTitle("Clear MP4: Dizzy").build(),
mimeType = MIME_TYPE_VIDEO_MP4,
)
),
handleLifecycle = true,
autoPlay = true,
usePlayerController = true,
enablePip = true,
handleAudioFocus = true,
controllerConfig = VideoPlayerControllerConfig.Default.copy(
showSpeedAndPitchOverlay = false,
showSubtitleButton = false,
showCurrentTimeAndTotalTime = true,
showBufferingProgress = false,
showForwardIncrementButton = true,
showBackwardIncrementButton = true,
showBackTrackButton = true,
showNextTrackButton = true,
showRepeatModeButton = true,
controllerShowTimeMilliSeconds = 5_000,
controllerAutoShow = true,
showFullScreenButton = false
),
volume = 0.5f, // volume 0.0f to 1.0f
repeatMode = repeatMode, // or RepeatMode.ALL, RepeatMode.ONE
onCurrentTimeChanged = { // long type, current player time (millisec)
Log.e("CurrentTime", it.toString())
},
playerInstance = { // ExoPlayer instance (Experimental)
addAnalyticsListener(object : AnalyticsListener {
@SuppressLint("UnsafeOptInUsageError")
override fun onRepeatModeChanged(
eventTime: AnalyticsListener.EventTime,
rMode: Int,
) {
repeatMode = rMode.toRepeatMode()
Toast.makeText(
context,
"RepeatMode changed = ${rMode.toRepeatMode()}",
Toast.LENGTH_LONG,
)
.show()
}
@SuppressLint("UnsafeOptInUsageError")
override fun onPlayWhenReadyChanged(
eventTime: AnalyticsListener.EventTime,
playWhenReady: Boolean,
reason: Int,
) {
Toast.makeText(
context,
"isPlaying = $playWhenReady",
Toast.LENGTH_LONG,
)
.show()
}
@SuppressLint("UnsafeOptInUsageError")
override fun onVolumeChanged(
eventTime: AnalyticsListener.EventTime,
volume: Float,
) {
Toast.makeText(
context,
"Player volume changed = $volume",
Toast.LENGTH_LONG,
)
.show()
}
}
)
},
modifier = Modifier
.fillMaxSize()
// .align(Alignment.Center),
)
}
Can You Please Add video Preload Option ?
When screen rotates all jetpack compose components lose the remembers states.
Player is reset and in consequence video track is set on start by default.
Trying use:
I want to show loading spinner while the media is loading. For that I think I need a callback for media loaded.
Is it possible with the current api?
Any plans to upgrade to Media3 from Exoplayer?
After override the context configuration to prevent font scaling and density scaling, the full screen dialog displays an error.
override fun attachBaseContext(newBase: Context) {
val resources = newBase.resources
val overrideConfiguration = Configuration(resources.configuration)
.apply {
fontScale = 1.0f
densityDpi = resources.displayMetrics.xdpi.toInt()
}
super.attachBaseContext(
newBase.createConfigurationContext(overrideConfiguration)
)
}
After set defaultPlayerView background to GRAY.
DisposableEffect(
AndroidView(
modifier = modifier,
factory = {
defaultPlayerView.apply {
useController = usePlayerController
resizeMode = surfaceResizeMode.toPlayerViewResizeMode()
setBackgroundColor(Color.GRAY)
}
},
),
) {
Hi,
I really, really, like this library. Much much easier to use than the 400+ line ExoPlayer "getting started" demo.
I needed to use the OkHttp DataSource (to enable playing videos that a user has downloaded offline via an OkHttp interceptor I made).
The current function signatures don't allow setting the DataSource.Factory. I made a fork with an option for the HttpDataSource here:
https://github.com/UstadMobile/compose-video
Add argument:
httpDataSourceFactory: HttpDataSource.Factory = remember {
DefaultHttpDataSource.Factory()
},
Use it:
.apply {
val cache = VideoPlayerCacheManager.getCache()
if (cache != null) {
val cacheDataSourceFactory = CacheDataSource.Factory()
.setCache(cache)
.setUpstreamDataSourceFactory(DefaultDataSource.Factory(context, httpDataSourceFactory))
setMediaSourceFactory(DefaultMediaSourceFactory(cacheDataSourceFactory))
} else {
setMediaSourceFactory(DefaultMediaSourceFactory(httpDataSourceFactory))
}
}
It's now working with OkHttpDataSource. I'm not sure if that is the most elegant API. Maybe accepting the DataSource.Factory itself would be an option?
I'm happy to tidy submit this into a pull request if that helps.
I want to add Video quality change options. Can anyone help me ?
What if this library supports kotlin multiplatform?
I'am asking for your opinion on whether you are in favor of updating the library so that it can be used on Kotlin multiplatform.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.