Prevent screen turning off during playback
Closes: #157 XDG portals expose a D-Bus interface allowing apps to prevent screen idling, user switching, and other actions. That interface, org.freedesktop.portal.Inhibit, does all of the heavy lifting here. Idling = the screen dimming or shutting off. Idling is inhibited when a video is actively playing. Idling is NOT inhibited when videos aren't playing - this includes paused or stopped videos.
This commit is contained in:
parent
fa1637fe51
commit
bb087578df
10 changed files with 331 additions and 40 deletions
15
src/video.rs
15
src/video.rs
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
use iced_video_player::{
|
||||
Video,
|
||||
gst::{self, prelude::*},
|
||||
gst_app, gst_pbutils, Video,
|
||||
gst_app, gst_pbutils,
|
||||
};
|
||||
|
||||
use cosmic::app::{Command, message};
|
||||
|
||||
pub fn new_video(url: &url::Url) -> Result<Video, cosmic::Command<cosmic::app::Message<super::Message>>> {
|
||||
pub fn new_video(
|
||||
url: &url::Url,
|
||||
) -> 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();
|
||||
|
|
@ -26,7 +28,10 @@ pub fn new_video(url: &url::Url) -> Result<Video, cosmic::Command<cosmic::app::M
|
|||
};
|
||||
if let Some(factory) = elem.factory() {
|
||||
if factory.name() == "souphttpsrc" {
|
||||
elem.set_property("user-agent", "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0");
|
||||
elem.set_property(
|
||||
"user-agent",
|
||||
"Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0",
|
||||
);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
@ -71,4 +76,4 @@ pub fn new_video(url: &url::Url) -> Result<Video, cosmic::Command<cosmic::app::M
|
|||
Err(Command::batch(commands))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue