Add share intent support (single & multi-file) with proper non-video handling#1778
Add share intent support (single & multi-file) with proper non-video handling#1778NarayanChetri wants to merge 4 commits into
Conversation
|
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! |
|
Hey @anilbeesetti , thanks for the detailed review! 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. 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. |
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