I need to have a video play on the background (ful...
# compose
s
I need to have a video play on the background (full screen) behind all the content, for the login screen basically. What options do I have with compose when showing a video like that? I’ve used normal compose
Image
or Coil for static images, but not sure where I should be headed towards with a video. The video format can be adjusted too, so looking for the best way to do this in general.
m
look into media3
s
Right, I felt like media3 might be for much more than that, my video feels like a gif, playing in the background without any controls over pausing/starting etc. and also no sound coming from it either. I could definitely be wrong though and media3 is the way to go, but just checking before I bring in such a big dependency for this
m
there you have it. you can use coil extension for gifs then
s
Aha, coil supports gif! Maybe this is the way to go then, I will try and look into that, and if the video can be converted to gif in a way that will be of reasonable quality. Right now we got the raw video from the designers, so we can probably try and get it in whatever format suits us, and I’m trying to make the right decision form the get go
a
GIFs have a couple of major issues, though. File size bloats up compared to mp4 because GIFs effectively store each frame. The longer it is, the more obvious the ballooning. This might also raise a possibility of OOM on device, not sure. Second, perceived FPS/smoothness. Your designers may not like the end result of a GIF because it's fundamentally different from most video formats.
If your videos are just vectors morphing around, you can probably go for AnimatedVectorPainter
I opted to go for a third-party lib to handle all video playback, including as a scrim to a ModalBottomSheet (custom)
I might come back to media3's exoplayer though
s
The videos are actual videos here, can’t do any vector morphing around and so on unfortunately.
Thanks for the info for gif, yeah it does sound like it is not what I want here. What library did you use then in your case?
a
Just checked, and as it turns out the lib we use is just a wrapper over exoplayer, haha. Good thing we're still iterating, might as well nuke the middleman
s
Exoplayer, so basically if I am doing smth from scratch now, might as well go with media3 directly
a
Looks like it
c
ExoPlayer is an adaptive media player for streaming video, which is probably overkill for your use case. Though I’m not actually too familiar with just playing looping local video on the device. I would expect a simpler solution is available
The last time I worked with Exo though it wasn’t yet part of the Android framework. So maybe things have changed!
m
Just use media3. A compose wrapper is easy to do. And the size addition is not that much. I dont think you have a better and reliable solution
a
If there's only 1 video (or just a few), bundle them into the app and try out
android.widget.VideoView
. You'll have to wrap it in Compose AndroidView of course.
Or maybe it can play remote URLs too? Haven't used that in a while
s
Yeah media3 is the new exoplayer now, that’s what I understood from reading up about it. So while it may be overkill, I may be able to just use a limited amount of features that they provide and be ok with it.
a
I would just use VideoView. Looking at the pros and cons of ExoPlayer, literally only the first advantage is relevant for your use case, and I don't believe a single video which you can completely control can have any issue across different devices and Android versions.
s
I wasn't even aware VideoView exists, that's why I'm here asking basically 😅 all I found when googling was exoplayer posts so I must've googled wrong 🫣 Will give VideoView a shot too, we need so little from media3 anyway that if I can get away without using it, I'd be very happy. Thanks Albert!
r
I would highly recommend media3 or exoplayer
1
s
Is it because even though I only need this "Fewer device-specific issues and less variation in behavior across different devices and versions of Android." point listed there, and I'm gonna use it for 1 video in one part of the app, it's still important enough that I should bring in media3 dependency in? Also you say exoplayer or media3, I suspect since I don't already have exoplayer in, there's no reason not to go with media3 right?
186 Views