diff --git a/src/utils.rs b/src/utils.rs index e8c68c5..9e64d8d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -99,7 +99,7 @@ pub fn open_external(url: &str) -> Result<()> { #[cfg(feature = "media")] /// Opens a media file with `mpv`. pub fn open_media(url: &str) -> Result<()> { - use crate::terminal; + use {crate::terminal, std::io}; // mpv only supports /9/ let url = url.replace("/;/", "/9/").replace("/s/", "/9/"); @@ -119,6 +119,11 @@ pub fn open_media(url: &str) -> Result<()> { } }; + // clear screen first + let mut stdout = io::stdout(); + write!(stdout, "{}{}", terminal::ClearAll, terminal::Goto(1, 1))?; + stdout.flush()?; + terminal::disable_raw_mode()?; let mut cmd = process::Command::new("mpv") .arg(url)