Spawn player with CREATE_BREAKAWAY_FROM_JOB on Windows
This commit is contained in:
parent
4aa4ca5d8c
commit
4fcc2ac31f
1 changed files with 19 additions and 6 deletions
|
@ -70,12 +70,25 @@ impl Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn launch_mpv(command: String, args: Vec<String>, url: &str) -> Result<(), io::Error> {
|
fn launch_mpv(command: String, args: Vec<String>, url: &str) -> Result<(), io::Error> {
|
||||||
process::Command::new(command)
|
let mut command = process::Command::new(command);
|
||||||
.stdout(process::Stdio::null())
|
|
||||||
.stderr(process::Stdio::null())
|
command.stdout(process::Stdio::null());
|
||||||
.args(args)
|
command.stderr(process::Stdio::null());
|
||||||
.arg(url)
|
command.args(args);
|
||||||
.spawn()?;
|
command.arg(url);
|
||||||
|
|
||||||
|
// NOTE: On Windows, browser spawns process into a Job object.
|
||||||
|
// NOTE: We need to detach player from the job, so it won't get killed after we're done,
|
||||||
|
// NOTE: See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#closing_the_native_app
|
||||||
|
#[cfg(target_family = "windows")]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
const CREATE_BREAKAWAY_FROM_JOB: u32 = 0x01000000;
|
||||||
|
|
||||||
|
command.creation_flags(CREATE_BREAKAWAY_FROM_JOB);
|
||||||
|
}
|
||||||
|
|
||||||
|
command.spawn()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue