Skip to content

Add Video screen viewer, FeedVideoPlayer, plus support for popular non OGP videohosts.#1922

Merged
dessalines merged 11 commits intoLemmyNet:mainfrom
MV-GH:video-screen-viewer
Aug 19, 2025
Merged

Add Video screen viewer, FeedVideoPlayer, plus support for popular non OGP videohosts.#1922
dessalines merged 11 commits intoLemmyNet:mainfrom
MV-GH:video-screen-viewer

Conversation

@MV-GH
Copy link
Copy Markdown
Collaborator

@MV-GH MV-GH commented Aug 17, 2025

  • Add VideoViewerScreen (like ImageViewerScreen)
  • Add FeedVideoPlayer (This was complex)
    • Add EmbeddedDataLoader
    • Global "active" video state tracking
  • Add Infra for custom videohosts + popular non OGP videohosts
  • Add aspectRatio to prevent feedhopping for "normal" image flow
  • Fix warning: "future" annotation will be applied to both paramater and field...
  • Remove explicit placeholder declaration, was already set on the imageloader itself
  • Use jerboa mono as placeholder instead (much smaller svg)

This took more time then anticipated. Lots of small problems that add up.

Fixes #1802

@MV-GH MV-GH requested a review from dessalines as a code owner August 17, 2025 21:41
Copy link
Copy Markdown
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/src/main/java/com/jerboa/feat/SwipeToAction.kt
Comment thread app/src/main/java/com/jerboa/Utils.kt
}

@Composable
fun EmbeddedVideoPlayer(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems really weird that a library for this wouldn't already exist. You're even rendering volume and playback buttons.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, exoplayer themselves come with prebuild ui (its unusable, not a surprise noone uses it)

I had also checked out the following libraries:

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.

Comment thread app/src/main/java/com/jerboa/ui/components/common/MarkdownHelper.kt
fullBody = true,
account = account,
postViewMode = PostViewMode.Card,
postViewMode = PostViewMode.SmallCard,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Card should probably stay default

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K that's pry fine then.

Comment on lines +8 to +10
* 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found these:

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I would have liked to have used a library. But

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MV-GH
Copy link
Copy Markdown
Collaborator Author

MV-GH commented Aug 18, 2025

Testing instructions:

  • Scroll feed until come across video, in Card mode and small card mode.
  • Also test out ScreenVideoViewer by clicking on a video.
  • you can test lifecycle pauzing by dragging Jerboa into the background and it should pauze and resume once brought back.

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 {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not good with names, and Manager has fallen out of grace 😄

android:width="300dp"
android:height="300dp"
android:width="200dp"
android:height="200dp"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings on too big 🤷 , bad for perf or something

@dessalines
Copy link
Copy Markdown
Member

I'll test this soon.

@dessalines
Copy link
Copy Markdown
Member

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.

@dessalines dessalines merged commit ef9517a into LemmyNet:main Aug 19, 2025
1 check passed
@MV-GH
Copy link
Copy Markdown
Collaborator Author

MV-GH commented Aug 19, 2025

You can do a release anything time you want. I have tested this build for a fair bit now.

If we got streaming torrent videos bundled into jerboa,

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.

@dessalines
Copy link
Copy Markdown
Member

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.

Newpipe can display peertube videos natively (or looks natively at least) so I believe proper peertube support should also be possible.

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.

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.

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 main running.

user: admin
pass: password

@dessalines
Copy link
Copy Markdown
Member

I'll do a release shortly.

@MV-GH
Copy link
Copy Markdown
Collaborator Author

MV-GH commented Aug 20, 2025

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.

? peertube doesnt expose the video url in the OGP tags? the og:video:url links to iframe blob

@dessalines
Copy link
Copy Markdown
Member

Dang, that's unfortunate. We could open up an issue there to expose it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Video Support

2 participants