Implement audio range requests
This commit enables serving audio files via HTTP Range requests. This is crucial for allowing HTML5 audio players to seek to specific positions within an audio file without re-downloading the entire file. The changes include: - Modifying `handle_audio` in `server/src/routes/web.rs` to parse `Range` headers. - Implementing `serve_range` to handle partial content responses. - Adding a `parse_range` helper function. - Updating tests to verify range request functionality. - Adding `ACCEPT_RANGES: bytes` header to indicate support for range requests. - Storing recording duration in a sidecar file for faster UI rendering. - Enhancing the HTML template to support a custom audio player with seeking.
This commit is contained in:
+10
-14
@@ -292,20 +292,16 @@ impl DoctateApp {
|
||||
// Fire-and-forget on the runtime. Blocking the egui UI thread on
|
||||
// an HTTP round-trip would freeze the window for ~100–500ms.
|
||||
self.runtime.spawn(async move {
|
||||
let url = match crate::magic_link::build_magic_url(
|
||||
&http,
|
||||
&server_url,
|
||||
&api_key,
|
||||
&return_to,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(u) => u,
|
||||
Err(e) => {
|
||||
warn!(error = %e, "magic-link request failed; falling back to plain URL");
|
||||
fallback_url
|
||||
}
|
||||
};
|
||||
let url =
|
||||
match crate::magic_link::build_magic_url(&http, &server_url, &api_key, &return_to)
|
||||
.await
|
||||
{
|
||||
Ok(u) => u,
|
||||
Err(e) => {
|
||||
warn!(error = %e, "magic-link request failed; falling back to plain URL");
|
||||
fallback_url
|
||||
}
|
||||
};
|
||||
if let Err(e) = webbrowser::open(&url) {
|
||||
warn!(url = %url, error = %e, "open browser failed");
|
||||
}
|
||||
|
||||
@@ -117,4 +117,3 @@ mod tests {
|
||||
assert!(!url.contains("//web/"), "double slash leaked: {url}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user