mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-18 23:32:48 +00:00
Player: launch external player via play-external IPC
Some checks failed
Continuous integration / test (push) Has been cancelled
Some checks failed
Continuous integration / test (push) Has been cancelled
This commit is contained in:
parent
bbbe882faf
commit
368a0062ed
1 changed files with 46 additions and 0 deletions
|
|
@ -298,6 +298,52 @@ impl MainWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some("play-external") => {
|
||||||
|
if let Some(arg) = msg.get_params() {
|
||||||
|
let arg = arg.as_str().unwrap_or("");
|
||||||
|
let arg_lc = arg.to_lowercase();
|
||||||
|
const ALLOWED_SCHEMES: &[&str] = &["mpv://", "vlc://", "potplayer://"];
|
||||||
|
let allowed = ALLOWED_SCHEMES.iter().any(|s| arg_lc.starts_with(s));
|
||||||
|
if !arg.is_empty() && allowed {
|
||||||
|
if let Some(stream_url) =
|
||||||
|
arg_lc.starts_with("mpv://").then(|| &arg[6..])
|
||||||
|
{
|
||||||
|
// `--` ends mpv's option parsing; the stream URL can't smuggle flags.
|
||||||
|
let mpv_paths: Vec<String> = vec![
|
||||||
|
std::env::var("ProgramFiles")
|
||||||
|
.ok()
|
||||||
|
.map(|v| format!("{v}\\mpv\\mpv.exe")),
|
||||||
|
std::env::var("ProgramFiles(x86)")
|
||||||
|
.ok()
|
||||||
|
.map(|v| format!("{v}\\mpv\\mpv.exe")),
|
||||||
|
std::env::var("LOCALAPPDATA")
|
||||||
|
.ok()
|
||||||
|
.map(|v| format!("{v}\\Programs\\mpv\\mpv.exe")),
|
||||||
|
std::env::var("LOCALAPPDATA")
|
||||||
|
.ok()
|
||||||
|
.map(|v| format!("{v}\\mpv\\mpv.exe")),
|
||||||
|
Some("mpv.exe".to_string()),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.collect();
|
||||||
|
for path in &mpv_paths {
|
||||||
|
if Command::new(path)
|
||||||
|
.arg("--")
|
||||||
|
.arg(stream_url)
|
||||||
|
.creation_flags(CREATE_BREAKAWAY_FROM_JOB)
|
||||||
|
.spawn()
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
open::that(arg).ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some("win-focus") => {
|
Some("win-focus") => {
|
||||||
focus_sender.notice();
|
focus_sender.notice();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue