Fix cosmic-player file launch and video playback
Some checks failed
Validate .desktop files / validate (push) Has been cancelled
Some checks failed
Validate .desktop files / validate (push) Has been cancelled
This commit is contained in:
parent
4a1bfc975c
commit
e7781986f5
5 changed files with 67 additions and 22 deletions
33
src/main.rs
33
src/main.rs
|
|
@ -8,10 +8,10 @@ use cosmic::iced::event::{self, Event};
|
|||
use cosmic::iced::keyboard::key::Physical;
|
||||
use cosmic::iced::keyboard::{Event as KeyEvent, Key, Modifiers};
|
||||
use cosmic::iced::mouse::{Event as MouseEvent, ScrollDelta};
|
||||
use cosmic::iced::window::set_mode;
|
||||
use cosmic::iced::{
|
||||
Alignment, Background, Border, Color, ContentFit, Length, Limits, Subscription, exit, window,
|
||||
};
|
||||
use cosmic::iced::window::set_mode;
|
||||
use cosmic::widget::menu::action::MenuAction;
|
||||
use cosmic::widget::{self, Slider, about::About, nav_bar, segmented_button};
|
||||
use cosmic::{Application, ApplicationExt, Element, action, cosmic_theme, executor, font, theme};
|
||||
|
|
@ -107,16 +107,6 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
match fork::daemon(true, true) {
|
||||
Ok(fork::Fork::Child) => (),
|
||||
Ok(fork::Fork::Parent(_child_pid)) => process::exit(0),
|
||||
Err(err) => {
|
||||
eprintln!("failed to daemonize: {:?}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
localize::localize();
|
||||
|
||||
let config = match cosmic_config::Config::new(App::APP_ID, CONFIG_VERSION) {
|
||||
|
|
@ -169,6 +159,18 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn stream_tags(pipeline: &gst::Pipeline, signal: &str, stream: i32) -> Option<gst::TagList> {
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
pipeline.emit_by_name::<Option<gst::TagList>>(signal, &[&stream])
|
||||
})) {
|
||||
Ok(tags) => tags,
|
||||
Err(_) => {
|
||||
log::warn!("failed to read {signal} for stream {stream}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Action {
|
||||
About,
|
||||
|
|
@ -417,14 +419,15 @@ impl App {
|
|||
|
||||
let n_video = pipeline.property::<i32>("n-video");
|
||||
for i in 0..n_video {
|
||||
let tags: gst::TagList = pipeline.emit_by_name("get-video-tags", &[&i]);
|
||||
log::info!("video stream {i}: {tags:#?}");
|
||||
if let Some(tags) = stream_tags(&pipeline, "get-video-tags", i) {
|
||||
log::info!("video stream {i}: {tags:#?}");
|
||||
}
|
||||
}
|
||||
|
||||
let n_audio = pipeline.property::<i32>("n-audio");
|
||||
self.audio_codes = Vec::with_capacity(n_audio as usize);
|
||||
for i in 0..n_audio {
|
||||
let tags: gst::TagList = pipeline.emit_by_name("get-audio-tags", &[&i]);
|
||||
let tags = stream_tags(&pipeline, "get-audio-tags", i).unwrap_or_default();
|
||||
log::info!("audio stream {i}: {tags:#?}");
|
||||
self.audio_codes
|
||||
.push(if let Some(title) = tags.get::<gst::tags::Title>() {
|
||||
|
|
@ -446,7 +449,7 @@ impl App {
|
|||
name: fl!("off"),
|
||||
});
|
||||
for i in 0..n_text {
|
||||
let tags: gst::TagList = pipeline.emit_by_name("get-text-tags", &[&i]);
|
||||
let tags = stream_tags(&pipeline, "get-text-tags", i).unwrap_or_default();
|
||||
log::info!("text stream {i}: {tags:#?}");
|
||||
let name = if let Some(title) = tags.get::<gst::tags::Title>() {
|
||||
title.get().to_string()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue