1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-04 20:21:02 +02:00

feat(music): progress/seek bar in popup

Resolves #128.
This commit is contained in:
Jake Stanger 2023-06-29 18:17:13 +01:00
parent bd90167f4e
commit 12053f111a
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
5 changed files with 284 additions and 103 deletions

View file

@ -9,9 +9,17 @@ pub mod mpd;
#[cfg(feature = "music+mpris")]
pub mod mpris;
pub const TICK_INTERVAL_MS: u64 = 200;
#[derive(Clone, Debug)]
pub enum PlayerUpdate {
/// Triggered when the track or player state notably changes,
/// such as a new track playing, the player being paused, or a volume change.
Update(Box<Option<Track>>, Status),
/// Triggered at regular intervals while a track is playing.
/// Used to keep track of the progress through the current track.
ProgressTick(ProgressTick),
/// Triggered when the client disconnects from the player.
Disconnect,
}
@ -27,23 +35,27 @@ pub struct Track {
pub cover_path: Option<String>,
}
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub enum PlayerState {
Playing,
Paused,
Stopped,
}
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Status {
pub state: PlayerState,
pub volume_percent: u8,
pub duration: Option<Duration>,
pub elapsed: Option<Duration>,
pub volume_percent: Option<u8>,
pub playlist_position: u32,
pub playlist_length: u32,
}
#[derive(Clone, Copy, Debug)]
pub struct ProgressTick {
pub duration: Option<Duration>,
pub elapsed: Option<Duration>,
}
pub trait MusicClient {
fn play(&self) -> Result<()>;
fn pause(&self) -> Result<()>;
@ -51,6 +63,7 @@ pub trait MusicClient {
fn prev(&self) -> Result<()>;
fn set_volume_percent(&self, vol: u8) -> Result<()>;
fn seek(&self, duration: Duration) -> Result<()>;
fn subscribe_change(&self) -> broadcast::Receiver<PlayerUpdate>;
}