Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions src-tauri/src/integrations/addons/addon_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,15 +1960,41 @@ impl AddonApi {
));
}

let mime = if is_stream_atmos {
"audio/mp4"
let (mime, ext): (&'static str, &'static str) = if is_stream_atmos {
("audio/mp4", "m4a")
} else if lower.ends_with(".mp3") {
"audio/mpeg"
("audio/mpeg", "mp3")
} else if lower.ends_with(".m4a") || lower.ends_with(".mp4") {
"audio/mp4"
("audio/mp4", "m4a")
} else {
"audio/flac"
("audio/flac", "flac")
};
// Extensionless progressive URLs (e.g. /st/track/<id>) used to be
// handed straight to mpv on a single TLS connection, which buffered.
// Every progressive addon stream goes through the loopback server so
// the adaptive multi-connection fetcher actually sees it.
if !is_stream_atmos {
if let Some(local_url) = LocalMediaServer::global()
.url_for_direct(self.http.clone(), &direct, &media_cache_name, ext, mime)
.await
{
return Some((
ResolvedStream {
url: local_url,
mime_type: mime.to_string(),
bitrate_kbps,
audio_codec: codec.to_string(),
cache_key,
is_lossless: !mp3,
bit_depth,
sampling_rate_khz: sample_rate,
expires_at: Some(Utc::now() + ChronoDuration::hours(24)),
..Default::default()
},
Some(media_cache_name),
));
}
}
Some((
ResolvedStream {
url: direct,
Expand Down
Loading