Mute when thumbnailing

This commit is contained in:
Jeremy Soller 2026-01-16 13:41:07 -07:00
parent 2ee05bf8a6
commit ceb8f57ec7
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA
3 changed files with 11 additions and 4 deletions

View file

@ -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,
};

View file

@ -13,7 +13,7 @@ pub fn main(
) -> Result<(), Box<dyn Error>> {
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"))),
};

View file

@ -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<Video, cosmic::Command<cosmic::app::Message<super::Message>>> {
//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()