Skip to content

Add share intent support (single & multi-file) with proper non-video handling#1778

Open
NarayanChetri wants to merge 4 commits into
anilbeesetti:mainfrom
NarayanChetri:share-intent-feature
Open

Add share intent support (single & multi-file) with proper non-video handling#1778
NarayanChetri wants to merge 4 commits into
anilbeesetti:mainfrom
NarayanChetri:share-intent-feature

Conversation

@NarayanChetri

Copy link
Copy Markdown
Contributor

Right now there's no way to share a video to NextPlayer from other apps and have it just play. This PR adds that.
The tricky part: a lot of OEM apps (Realme/Oppo's built-in Photos/Gallery being the main one I ran into) don't show "NextPlayer" as an option when you hit share on a video, because they only offer apps that declare a specific video mime type filter, and some of them share with a generic type instead. To get around this, NextPlayer now also registers for the generic / share filter, so it shows up in every app's share sheet, not just the ones that explicitly tag their files as video.
But that creates a new problem: since we're now catching any shared file, people can accidentally (or on purpose) share a PDF, APK, image, etc. to NextPlayer. So I added a check that looks at the mime type of whatever got shared, and if it's not a video, it shows a "not a video file" toast and closes right away instead of opening a blank/broken player screen.

Also handles:
Single file share → plays just that file
Multiple file share (select several videos and share together) → plays them as a playlist, in order
Falls back gracefully if a sender doesn't set a mime type at all (some apps don't), instead of blocking a valid video

Tested on a Realme device (Android 16) sharing from the stock Photos app, a file manager, and WhatsApp.
I went with the / filter + runtime check approach instead of a strict video-only filter since that's what solves the OEM issue this PR is meant to fix. Happy to switch to a stricter video mime type filter instead if that's preferred — Do let me know if this works .

Fixes #1696

ref1 ref2 ref3

@NarayanChetri

Copy link
Copy Markdown
Contributor Author

Hi @anilbeesetti , just dropping a quick note to see if there's any feedback on this share intent implementation. Happy to make any necessary adjustments!

anilbeesetti

This comment was marked as resolved.

@anilbeesetti
anilbeesetti dismissed their stale review July 12, 2026 04:32

Dismissing this review.

@NarayanChetri

Copy link
Copy Markdown
Contributor Author

Hey @anilbeesetti , thanks for the detailed review!
Went through all the points:

Fixed the null mimeType fallback — it was letting non-videos through as "video" when the type couldn't be read. Now it falls back to checking the file extension, and if that's unclear too, it just treats it as not-a-video so the toast shows instead of a broken player. Honestly couldn't reproduce the exact broken screen on my end, but the logic was clearly wrong either way, so fixed it based on your report.
Fixed the manifest indentation on the 4 new intent-filters to match the rest of the file.
Moved the hardcoded "Play with Next Player" label into a string resource so it can be translated like everything else.
Added the missing trailing newline in PlayerActivity.kt.
Left the / vs video/* filter as is for now since that's really your call on the breadth-vs-OEM-coverage tradeoff — happy to switch it if you'd rather go stricter.

If it's easier on your end, feel free to take over the PR and push directly to this branch — happy either way, whatever gets it merged faster.
Also sorry about the few extra commits that triggered multiple builds — forgot I already had this branch open and pushed some changes without realizing it'd kick off the CI again. Will be more careful with that going forward.
Let me know if anything else needs changing!

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.

Share to Nextplayer

2 participants