Mute when thumbnailing
This commit is contained in:
parent
2ee05bf8a6
commit
ceb8f57ec7
3 changed files with 11 additions and 4 deletions
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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"))),
|
||||
};
|
||||
|
|
|
|||
11
src/video.rs
11
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<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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue