mirror of
https://github.com/yattee/yattee.git
synced 2026-07-20 14:22:02 +00:00
Apply audio mode to downloaded videos
Downloads bypass stream selection and reach play() as ready-made local file streams, so audio mode never affected them. Apply the mode at that choke point instead: swap a local video stream for the separately downloaded audio track, or play a muxed file with the video track disabled (vid set per-load in MPVClient, never toggled live). The transform is bidirectional so stored audio-only queue/history entries restore full video when the mode is off, and setAudioMode now reloads downloaded content at the current position in both directions.
This commit is contained in:
@@ -189,6 +189,38 @@ struct StreamResolution: Codable, Hashable, Sendable, Comparable, CustomStringCo
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Audio-Only Variant
|
||||
|
||||
extension Stream {
|
||||
/// Whether the backend must disable the video track when loading this stream:
|
||||
/// a muxed file being played as audio-only (see `audioOnlyVariant()`).
|
||||
var requiresVideoTrackDisabled: Bool {
|
||||
isAudioOnly && videoCodec != nil
|
||||
}
|
||||
|
||||
/// Creates an audio-only copy of this stream keeping the same URL.
|
||||
/// Used for muxed local files in audio mode: `videoCodec` stays set so
|
||||
/// `requiresVideoTrackDisabled` tells the backend to skip the video track.
|
||||
func audioOnlyVariant() -> Stream {
|
||||
Stream(
|
||||
url: url,
|
||||
resolution: nil,
|
||||
format: format,
|
||||
videoCodec: videoCodec,
|
||||
audioCodec: audioCodec,
|
||||
bitrate: bitrate,
|
||||
fileSize: fileSize,
|
||||
isAudioOnly: true,
|
||||
isLive: isLive,
|
||||
mimeType: mimeType,
|
||||
audioLanguage: audioLanguage,
|
||||
audioTrackName: audioTrackName,
|
||||
isOriginalAudio: isOriginalAudio,
|
||||
httpHeaders: httpHeaders
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - URL Rewriting
|
||||
|
||||
extension Stream {
|
||||
|
||||
Reference in New Issue
Block a user