Add Video screen viewer, FeedVideoPlayer, plus support for popular non OGP videohosts.#1922
Conversation
There was a problem hiding this comment.
My main concern here is that its so much custom code for us to maintain. You basically built an entire exoplayer wrapper from scratch, with jerboa-specific features.
Is there any reason we couldn't use an existing video player library, like
Also, I need some testing instructions.
| } | ||
|
|
||
| @Composable | ||
| fun EmbeddedVideoPlayer( |
There was a problem hiding this comment.
Seems really weird that a library for this wouldn't already exist. You're even rendering volume and playback buttons.
There was a problem hiding this comment.
Well, exoplayer themselves come with prebuild ui (its unusable, not a surprise noone uses it)
I had also checked out the following libraries:
- https://github.com/Chaintech-Network/ComposeMultiplatformMediaPlayer (by far the best one)
- https://github.com/dsa28s/compose-video
Now the reason why I didnt use one of those. Is because you won't find a library that happens to fit our UI needs/design.
Our design is fairly simple (Boost replica):
- when not loaded:
- show hostId
- show thumbnail
- when loading:
- show loading icon in right bottom corner
- show hostId
- show thumbnail
- when loaded: (only here would those libraries be able to do anything)
- show video
- show mute button left corners (easily tappable)
- show countdown right corner bottom corner
(There are no playback buttons.)
Now the real complexity is the switching to the active "video". There can be multiple videos visible. (And it must be seamless reason 'isExoPlayerInitialized")
None of those existing libraries do this. This must be manually implemented. As such you can see quite a bit of code for this. Had to figure this all out myself because I couldn't find any existing implementations for Compose.
| fullBody = true, | ||
| account = account, | ||
| postViewMode = PostViewMode.Card, | ||
| postViewMode = PostViewMode.SmallCard, |
There was a problem hiding this comment.
Card should probably stay default
There was a problem hiding this comment.
I followed boost behaviour here, when in "single" post mode it shows the little square. Imo it is better. The only reason to open the post is to either read the full description or the comments. You can already fully see the image/video from the feed by clicking on the square.
| * Couldn't find any existing Java/Kotlin libs and | ||
| * didnt want to introduce whole XML parsing libs like Jsoup | ||
| * So I ended up with this bit of regex magic. |
There was a problem hiding this comment.
I found these:
- https://github.com/johndeverall/opengraph-java
- https://github.com/haroldadmin/opengraphKt
- https://github.com/tw-Frey/OpenGraph-Kotlin
Its much better to use existing libraries than to code from scratch, otherwise we have to do all the bug fixes.
If the libraries above don't work, and your code is useful, then you might as well make a library out of it. I did that recently in kotlin and can step you through it if you want.
There was a problem hiding this comment.
Yes I would have liked to have used a library. But
- https://github.com/johndeverall/opengraph-java this doesnt have a release and not maintained.
- https://github.com/haroldadmin/opengraphKt not maintained, brings in the whole Jsoup lib and single release, no actual usage, uses custom httpclient as entrypoint (we need ours to do the HTTP), uses old versions for all libs (kotlinx.coroutines..) that doubt would even compile with our current app.
- https://github.com/tw-Frey/OpenGraph-Kotlin is unchanged non maintained fork of https://github.com/haroldadmin/opengraphKt
In essence existing solutions are not maintained so, we would have to fix any bugs ourselfs regardless 🤷
I didn't make custom library for it because its <70 lines (with mostly fluff)
There was a problem hiding this comment.
Alright. Its kind of crazy to me that the entire java / kotlin ecosystem has no useable opengraph library. Someone should really make one or fork one of the repos above at some point.
|
Testing instructions:
I have posted a bunch of video in lemmy.word test see https://lemmy.world/c/test5677754 (if you cant find any videos you can go here or create some posts using those links) |
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.withContext | ||
|
|
||
| class VideoHostComposer { |
There was a problem hiding this comment.
Not good with names, and Manager has fallen out of grace 😄
| android:width="300dp" | ||
| android:height="300dp" | ||
| android:width="200dp" | ||
| android:height="200dp" |
There was a problem hiding this comment.
Warnings on too big 🤷 , bad for perf or something
|
I'll test this soon. |
|
Tested, and it works really well, excellent job. LMK when you'd like me to do a release for this. If we got streaming torrent videos bundled into jerboa, we'd be a potential youtube threat. There's a few android apps out there that have examples of it, using the java torrent libraries. |
|
You can do a release anything time you want. I have tested this build for a fair bit now.
I haven't heard of this, you would have to link some stuff. Newpipe can display peertube videos natively (or looks natively at least) so I believe proper peertube support should also be possible. It would also be nice if we could show gifs like videos (Boost can, not sure how) For that I have made a request here, not sure what will come from it. coil-kt/coil#3122 But my focus will be on getting 1.0.0 support. Now the types are more stable I can continue my work on that. |
|
Lemmy supports torrent magnet links as post urls. For now in the media docs, I'm recommending people use stremio when wanting to stream torrents, but it could be possible to build that in natively by bundling an android torrent client. Very low priority now tho.
For hosted things, we can just extract the video url from the opengraph tags, but that'll have to wait for 1.0 I think.
Thx for making that, I'll watch the issue. The 1.0 additions is def where I could use the most help. You can use https://voyager.lemmy.ml to test rn, which has the backend from user: |
|
I'll do a release shortly. |
? peertube doesnt expose the video url in the OGP tags? the og:video:url links to iframe blob |
|
Dang, that's unfortunate. We could open up an issue there to expose it. |
This took more time then anticipated. Lots of small problems that add up.
Fixes #1802