diff --git a/src/main.rs b/src/main.rs index 3b1a303..898575b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -369,7 +369,7 @@ impl App { self.flags.config_state.recent_files.truncate(10); self.save_config_state(); - let video = match video::new_video(&url) { + let video = match video::new_video(&url, video::VideoSettings::default()) { Ok(ok) => ok, Err(err) => return err, }; diff --git a/src/thumbnail.rs b/src/thumbnail.rs index 58c7314..e52731a 100644 --- a/src/thumbnail.rs +++ b/src/thumbnail.rs @@ -13,7 +13,7 @@ pub fn main( ) -> Result<(), Box> { let mut image = { let thumbnails = { - let mut video = match video::new_video(input) { + let mut video = match video::new_video(input, video::VideoSettings { mute: true }) { Ok(ok) => ok, Err(_err) => return Err(Into::into(format!("missing required plugin"))), }; diff --git a/src/video.rs b/src/video.rs index c91e9e9..c88942f 100644 --- a/src/video.rs +++ b/src/video.rs @@ -6,16 +6,23 @@ use iced_video_player::{ use cosmic::app::{Command, message}; +#[derive(Debug, Default)] +pub struct VideoSettings { + pub mute: bool, +} + pub fn new_video( url: &url::Url, + settings: VideoSettings, ) -> Result>> { //TODO: this code came from iced_video_player::Video::new and has been modified to stop the pipeline on error //TODO: remove unwraps and enable playback of files with only audio. gst::init().unwrap(); let pipeline = format!( - "playbin uri=\"{}\" video-sink=\"videoscale ! videoconvert ! videoflip method=automatic ! appsink name=iced_video drop=true caps=video/x-raw,format=NV12,pixel-aspect-ratio=1/1\"", - url.as_str() + "playbin uri=\"{}\"{} video-sink=\"videoscale ! videoconvert ! videoflip method=automatic ! appsink name=iced_video drop=true caps=video/x-raw,format=NV12,pixel-aspect-ratio=1/1\"", + url.as_str(), + if settings.mute { " mute=true" } else { "" } ); let pipeline = gst::parse::launch(pipeline.as_ref()) .unwrap()