feat(player): discover external audio tracks - #67
Conversation
📝 WalkthroughWalkthroughThe change adds external audio sidecar discovery, modeling, resolution, and playback. Standard Exo merges external audio sources. Embedded mpv loads and exposes external audio tracks. Unsupported backend combinations now return explicit errors. The application version changes to 2.8.0. ChangesExternal audio playback
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PlayerViewModel
participant PlaybackSidecarResolver
participant ExoPlaybackController
participant MiruMpvSurfaceView
PlayerViewModel->>PlaybackSidecarResolver: Resolve playback source
PlaybackSidecarResolver->>PlayerViewModel: Return source with externalAudioTracks
PlayerViewModel->>ExoPlaybackController: Start playback
ExoPlaybackController->>MiruMpvSurfaceView: Load media with externalAudioPaths
MiruMpvSurfaceView->>MiruMpvSurfaceView: Attach paths with audio-add
MiruMpvSurfaceView->>ExoPlaybackController: Report audio and subtitle track changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt`:
- Around line 289-297: Preserve sidecar language and title metadata across both
playback backends: in ExoPlaybackController at
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt:289-297,
populate the external track’s Format metadata when creating its MediaSource; at
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt:1561-1561,
pass full external-audio metadata rather than paths to embedded MPV; and in
MiruMpvSurfaceView at
player-mpv-android/src/main/kotlin/is/xyz/mpv/MiruMpvSurfaceView.kt:276-278,
apply or merge the supplied language and title when creating or publishing the
native audio track. Add a backend test covering a language-suffixed sidecar with
no embedded audio tags.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 165a3673-b18a-4efd-9ca6-e852e2d32d9b
📒 Files selected for processing (11)
app/build.gradle.ktscore/model/src/main/kotlin/com/miruplay/tv/model/ExternalAudioTracks.ktcore/model/src/main/kotlin/com/miruplay/tv/model/FileModels.ktcore/model/src/main/kotlin/com/miruplay/tv/model/PlaybackSource.ktcore/model/src/test/kotlin/com/miruplay/tv/model/ExternalAudioTracksTest.ktplayer-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.ktplayer-core/src/test/kotlin/com/miruplay/tv/player/ExternalAudioBackendSupportTest.ktplayer-mpv-android/src/main/kotlin/is/xyz/mpv/MiruMpvSurfaceView.ktrepository-api/src/main/kotlin/com/miruplay/tv/repository/PlaybackSidecarResolver.ktrepository-api/src/test/kotlin/com/miruplay/tv/repository/PlaybackSidecarResolverTest.ktui-tv/src/main/kotlin/com/miruplay/tv/ui/player/PlayerViewModel.kt
| source.externalAudioTracks.forEach { track -> | ||
| add( | ||
| mediaSourceFactory.createMediaSource( | ||
| MediaItem.Builder() | ||
| .setUri(track.path) | ||
| .setMediaMetadata(MediaMetadata.Builder().setTitle(track.title).build()) | ||
| .build(), | ||
| ), | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve sidecar language and title metadata through both playback backends.
ExternalAudioTrack.language is derived during discovery but does not reach the displayed backend track. Exo reads Format.language, and embedded MPV reads native track metadata. A file named Episode.en.ac3 without embedded tags will therefore appear as und or unnamed in the audio menu.
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt#L289-L297: preserve each external track language and title in the Exo audio-track representation.player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt#L1561-L1561: pass external-audio metadata, not only paths, to embedded MPV.player-mpv-android/src/main/kotlin/is/xyz/mpv/MiruMpvSurfaceView.kt#L276-L278: apply the supplied language and title when adding the native audio track, or merge the metadata when publishingTrackInfo.
Add a backend test for a sidecar with a language suffix and no embedded audio tags.
📍 Affects 2 files
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt#L289-L297(this comment)player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt#L1561-L1561player-mpv-android/src/main/kotlin/is/xyz/mpv/MiruMpvSurfaceView.kt#L276-L278
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt`
around lines 289 - 297, Preserve sidecar language and title metadata across both
playback backends: in ExoPlaybackController at
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt:289-297,
populate the external track’s Format metadata when creating its MediaSource; at
player-core/src/main/kotlin/com/miruplay/tv/player/ExoPlaybackController.kt:1561-1561,
pass full external-audio metadata rather than paths to embedded MPV; and in
MiruMpvSurfaceView at
player-mpv-android/src/main/kotlin/is/xyz/mpv/MiruMpvSurfaceView.kt:276-278,
apply or merge the supplied language and title when creating or publishing the
native audio track. Add a backend test covering a language-suffixed sidecar with
no embedded audio tags.
Summary
Backend behavior
Verification
Summary by CodeRabbit
New Features
Bug Fixes
Chores