Skip to content

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

Open
NarayanChetri wants to merge 1 commit 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 1 commit 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!

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

1 participant