Send correct reply and suppress mpv output

This prevents errors in the browser log
This commit is contained in:
Gabriel Vogel 2023-04-09 16:50:42 +02:00
parent 5d7c23124c
commit 3c9db73c54
2 changed files with 5 additions and 1 deletions

View file

@ -11,7 +11,8 @@ pub struct FF2MpvMessage {
}
pub fn send_reply() -> Result<(), io::Error> {
send_message("ok")
// "ok" formatted as a JSON string
send_message("\"ok\"")
}
pub fn get_mpv_message() -> Result<FF2MpvMessage, FF2MpvError> {

View file

@ -64,12 +64,15 @@ impl Command {
let config = Config::build();
let ff2mpv_message = browser::get_mpv_message()?;
Command::launch_mpv(config.player_command, config.player_args, &ff2mpv_message.url)?;
browser::send_reply()?;
Ok(())
}
fn launch_mpv(command: String, args: Vec<String>, url: &str) -> Result<(), io::Error> {
process::Command::new(command)
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.args(args)
.arg(url)
.spawn()?;