Skip to content

Improve seek reliability for local M4A/MP4 files and update `MediaIte…#1621

Merged
theovilardo merged 1 commit into
masterfrom
fix/ma4-flac-playback-isues
Apr 1, 2026
Merged

Improve seek reliability for local M4A/MP4 files and update `MediaIte…#1621
theovilardo merged 1 commit into
masterfrom
fix/ma4-flac-playback-isues

Conversation

@theovilardo

Copy link
Copy Markdown
Collaborator

…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.

…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.
@theovilardo theovilardo merged commit 3b4bcfd into master Apr 1, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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.

1 participant