Improve seek reliability for local M4A/MP4 files and update `MediaIte…#1621
Conversation
…m` construction
- **DualPlayerEngine**: Configure `Mp4Extractor` with `FLAG_WORKAROUND_IGNORE_EDIT_LISTS` to prevent seek drift and snap-back issues caused by broken edit lists in vendor-produced M4A files.
- **MediaItemBuilder**:
- Update `playbackUri` to prefer direct file URIs over `content://` URIs for specific local audio formats (M4A, MP4, AAC, 3GP, etc.) to improve playback stability.
- Implement `shouldPreferDirectLocalFileUri` to identify when a direct file path should be used based on MIME type and file extension.
- Centralize `MediaItem` URI generation by accepting `Song` objects directly.
- **PlayerViewModel**: Update `MediaItem` creation to include MIME types and use the updated `MediaItemBuilder.playbackUri` signature.
- **Tests**:
- Add `MediaItemBuilderTest` to verify direct file URI selection logic.
- Update `PlayerViewModelTest` to match the new `playbackUri` signature.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc2f1836aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return null | ||
| } | ||
|
|
||
| return Uri.fromFile(File(normalizedPath)) |
There was a problem hiding this comment.
Guard direct-file URI promotion with existence checks
playbackUri(...) now promotes eligible content:// items to file:// via directLocalFileUri, but this return is unconditional once MIME/extension matches. If the persisted Song.path is stale (for example after a rename/move where the MediaStore row/content:// ID is still valid), playback will fail on a missing file path even though the original content URI would still resolve. Add a File(normalizedPath).exists()/canRead() gate (or similar) before returning the file URI so it can fall back to content:// when the path is no longer valid.
Useful? React with 👍 / 👎.
…m` construction
Mp4ExtractorwithFLAG_WORKAROUND_IGNORE_EDIT_LISTSto prevent seek drift and snap-back issues caused by broken edit lists in vendor-produced M4A files.playbackUrito prefer direct file URIs overcontent://URIs for specific local audio formats (M4A, MP4, AAC, 3GP, etc.) to improve playback stability.shouldPreferDirectLocalFileUrito identify when a direct file path should be used based on MIME type and file extension.MediaItemURI generation by acceptingSongobjects directly.MediaItemcreation to include MIME types and use the updatedMediaItemBuilder.playbackUrisignature.MediaItemBuilderTestto verify direct file URI selection logic.PlayerViewModelTestto match the newplaybackUrisignature.