mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-03 16:41:26 +01:00
feat(app,android,ios): say when playback fails and offer to retry from there
A file mpv gave up on partway ended the desktop player without a word: the page went back to the title and the film was simply gone. It now leaves an error toast naming where it stopped, with Retry reopening the episode at that position. The phone players already showed an error, but its only button was Dismiss, so a dropped connection meant backing out and finding the episode again. They gain Retry, which opens a fresh stream (through the session refresh) from where the failed one stopped. A stall that lasts twenty seconds now says so and offers the same, rather than showing "Buffering…" for ever.
This commit is contained in:
1 parent
9e53a9bbdb
commit
c5490ab3da
5 files changed
+117
-8
No files matched your search
@@ -688,6 +688,30 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Say that the playing file failed, with a button that opens it again
|
||||
/// where it stopped — a dropped connection is the usual cause, and the
|
||||
/// session refresh behind the next open is usually the cure.
|
||||
fn offer_retry(&mut self, ctx: &egui::Context) {
|
||||
let Some(playback) = &self.playback else {
|
||||
return;
|
||||
};
|
||||
let mut retry = playback.target.clone();
|
||||
let at = if playback.position > 0.0 {
|
||||
playback.position
|
||||
} else {
|
||||
retry.resume_at.unwrap_or(0.0)
|
||||
};
|
||||
retry.resume_at = (at > 0.0).then_some(at);
|
||||
let text = format!(
|
||||
"{} stopped playing at {}",
|
||||
retry.title_name,
|
||||
crate::ui::format_time(at)
|
||||
);
|
||||
let now = ctx.input(|input| input.time);
|
||||
self.toasts
|
||||
.push_error_with(now, text, "Retry", Action::Play(retry));
|
||||
}
|
||||
|
||||
fn note(&mut self, ctx: &egui::Context, text: impl Into<String>, error: bool) {
|
||||
let now = ctx.input(|input| input.time);
|
||||
self.toasts.push(now, text, error);
|
||||
@@ -894,6 +918,16 @@ impl App {
|
||||
{
|
||||
self.autoplay_next(ctx);
|
||||
}
|
||||
// mpv gave up partway. The page is about to go back to the
|
||||
// title, and without this the film would simply vanish.
|
||||
if mine
|
||||
&& matches!(
|
||||
event,
|
||||
pstr_player::PlayerEvent::EndFile(pstr_player::EndReason::Failed)
|
||||
)
|
||||
{
|
||||
self.offer_retry(ctx);
|
||||
}
|
||||
}
|
||||
Event::PlayerStopped { id } => {
|
||||
if self.playback.as_ref().is_some_and(|p| p.id == id) {
|
||||
|
||||
@@ -52,6 +52,17 @@ impl Toasts {
|
||||
self.push_inner(now, text.into(), false, Some((label, action)));
|
||||
}
|
||||
|
||||
/// An error with a button on it — "Retry".
|
||||
pub fn push_error_with(
|
||||
&mut self,
|
||||
now: f64,
|
||||
text: impl Into<String>,
|
||||
label: &'static str,
|
||||
action: Action,
|
||||
) {
|
||||
self.push_inner(now, text.into(), true, Some((label, action)));
|
||||
}
|
||||
|
||||
fn push_inner(
|
||||
&mut self,
|
||||
now: f64,
|
||||
|
||||
Reference in new issue
Block a user