Add share intent support (single & multi-file) with proper non-video handling#1778
Open
NarayanChetri wants to merge 1 commit into
Open
Add share intent support (single & multi-file) with proper non-video handling#1778NarayanChetri wants to merge 1 commit into
NarayanChetri wants to merge 1 commit into
Conversation
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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