I’m trying to create a program that interacts with MPV in its CLI implementation
let mut output = Command::new("mpv")
.arg(selected_song.unwrap())
.arg("--no-video")
.arg("--vo=null")
.arg("--video=no")
.stdin(Stdio::piped())
.spawn()
.expect("Failed to execute command");
let mut mpv_stdin = output.stdin.as_ref().unwrap();
loop {
match get_pressed_key().unwrap().as_str() {
"exit" => {
let _ = mpv_stdin.write_all(b"q");
break;
},
"pause" => {
let _ = mpv_stdin.write_all(b"p");
println!("Pressed pause")
}
_ => {}
}
}
let _exit_status = output.wait();
I correctly match my “pause” event in get_pressed_key
and write “p” to mpv process standard input buffer, but nothing happens, the song keeps playing normally