Expand description
Subtitle and audio-track selection on mpv, by position, the way the frontend asks for it.
Until DR-235 mpv never drew video, so it never had to: subtitles were
<track> children of the webview <video> and an audio track change
re-opened the stream. With mpv the only desktop video renderer, it has to
answer the same two calls ExoPlayer does, with the same meaning:
- Subtitles are the sideloaded WebVTT list the play request carries
(
MediaItem::subtitles), andset_subtitle_track(n)selects the n-th of those — the position the frontend computes withnativeSubtitleArrayIndex. They reach mpv as external files queued onsub-filesbefore the load, and selection starts off, because the menu opens on “Off”. - Audio
set_audio_track(n)selects the n-th audio track of the file — the position in the item’s audio streams, which is file order. Only a direct play/stream carries every track; a transcode is re-opened instead (AudioTrackSwitchStrategy).
mpv’s own track ids are not positions: they count every track of a type,
embedded before external, from 1. So a position is always resolved against
the live track-list.
TRACES: UR-020, UR-021 | DR-023, DR-024, DR-235
Structs§
- Track
Info - One entry of mpv’s
track-list, reduced to what selection needs.
Functions§
- nth_
track_ id - The mpv id of the
position-th track ofkind(optionally only external or only embedded ones), intrack-listorder. - prepare_
load - Prepare the next
loadfile: these subtitle files will be loaded with it, no subtitle is shown, and the file’s default audio track plays. - select_
audio - Play the
position-th audio track of the file. - select_
subtitle - Show the
position-th sideloaded subtitle, or none. - track_
list - Read the current
track-list.