Skip to content

Commit

Permalink
Fix playback from offset
Browse files Browse the repository at this point in the history
  • Loading branch information
core1024 committed Dec 23, 2024
1 parent 7ca6228 commit f0d5a1c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/stremio_app/stremio_player/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,20 @@ stringable!(MpvCmd);
pub enum CmdVal {
Single((MpvCmd,)),
Double(MpvCmd, String),
Tripple(MpvCmd, String, String),
Quadruple(MpvCmd, String, String, String),
Quintuple(MpvCmd, String, String, String, String),
}
impl From<CmdVal> for Vec<String> {
fn from(cmd: CmdVal) -> Vec<String> {
match cmd {
CmdVal::Single(cmd) => vec![cmd.0.to_string()],
CmdVal::Double(cmd, arg) => vec![cmd.to_string(), arg],
CmdVal::Tripple(cmd, arg1, arg2) => vec![cmd.to_string(), arg1, arg2],
CmdVal::Quadruple(cmd, arg1, arg2, arg3) => vec![cmd.to_string(), arg1, arg2, arg3],
CmdVal::Quintuple(cmd, arg1, arg2, arg3, arg4) => {
vec![cmd.to_string(), arg1, arg2, arg3, arg4]
}
}
}
}
Expand Down
33 changes: 29 additions & 4 deletions src/stremio_app/stremio_player/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,36 @@ fn create_message_thread(
};

let send_command = |cmd: CmdVal| {
let (name, arg) = match cmd {
CmdVal::Double(name, arg) => (name, format!(r#""{arg}""#)),
CmdVal::Single((name,)) => (name, String::new()),
let a1;
let a2;
let a3;
let a4;
let (name, args) = match cmd {
CmdVal::Quintuple(name, arg1, arg2, arg3, arg4) => {
a1 = format!(r#""{arg1}""#);
a2 = format!(r#""{arg2}""#);

Check warning on line 170 in src/stremio_app/stremio_player/player.rs

View workflow job for this annotation

GitHub Actions / test

Diff in \\?\D:\a\stremio-shell-ng\stremio-shell-ng\src\stremio_app\stremio_player\player.rs
a3 = format!(r#""{arg3}""#);
a4 = format!(r#""{arg4}""#);
(name, vec![a1.as_ref(), a2.as_ref(), a3.as_ref(), a4.as_ref()])
}
CmdVal::Quadruple(name, arg1, arg2, arg3) => {
a1 = format!(r#""{arg1}""#);
a2 = format!(r#""{arg2}""#);
a3 = format!(r#""{arg3}""#);

Check warning on line 178 in src/stremio_app/stremio_player/player.rs

View workflow job for this annotation

GitHub Actions / test

Diff in \\?\D:\a\stremio-shell-ng\stremio-shell-ng\src\stremio_app\stremio_player\player.rs
(name, vec![a1.as_ref(), a2.as_ref(), a3.as_ref()])
}
CmdVal::Tripple(name, arg1, arg2 ) => {
a1 = format!(r#""{arg1}""#);
a2 = format!(r#""{arg2}""#);
(name, vec![a1.as_ref(), a2.as_ref()])
},

Check warning on line 185 in src/stremio_app/stremio_player/player.rs

View workflow job for this annotation

GitHub Actions / test

Diff in \\?\D:\a\stremio-shell-ng\stremio-shell-ng\src\stremio_app\stremio_player\player.rs
CmdVal::Double(name, arg1) => {
a1 = format!(r#""{arg1}""#);
(name, vec![a1.as_ref()])
}
CmdVal::Single((name,)) => (name, vec![]),
};
if let Err(error) = mpv.command(&name.to_string(), &[&arg]) {
if let Err(error) = mpv.command(&name.to_string(), &args) {
eprintln!("failed to execute MPV command: '{error:#}'")
}
};
Expand Down

0 comments on commit f0d5a1c

Please sign in to comment.