🚧 Start on Now Playing stuff

This commit is contained in:
Lucy 2022-04-08 11:53:23 -04:00
parent 73d2401ed3
commit 8c196a7ed3
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
2 changed files with 26 additions and 0 deletions

View file

@ -5,6 +5,7 @@ extern crate relm4_macros;
mod icons;
mod input;
mod now_playing;
mod output;
mod pa;
mod task;
@ -21,6 +22,7 @@ use libpulse_binding::{
context::subscribe::{Facility, InterestMaskSet, Operation},
volume::Volume,
};
use mpris2_zbus::metadata::Metadata;
use once_cell::sync::Lazy;
use pulsectl::Handler;
use tokio::runtime::Runtime;
@ -44,6 +46,7 @@ fn app(application: &Application) {
}));
let (refresh_output_tx, refresh_output_rx) = MainContext::channel::<()>(PRIORITY_DEFAULT);
let (refresh_input_tx, refresh_input_rx) = MainContext::channel::<()>(PRIORITY_DEFAULT);
let (now_playing_tx, now_playing_rx) = MainContext::channel::<Vec<Metadata>>(PRIORITY_DEFAULT);
handler
.context
.borrow_mut()
@ -168,5 +171,11 @@ fn app(application: &Application) {
Continue(true)
}),
);
now_playing_rx.attach(
None,
clone!(@weak playing_apps => @default-return Continue(true), move |all_metadata| {
Continue(true)
}),
);
window.show();
}

View file

@ -0,0 +1,17 @@
use gtk4::{glib::Sender, prelude::*, Button, Image, Label, ListBox};
use mpris2_zbus::{media_player::MediaPlayer, metadata::Metadata};
use std::time::Duration;
use tokio::time::sleep;
use zbus::Connection;
pub async fn metadata_update(tx: Sender<Vec<Metadata>>) {
let connection = Connection::session()
.await
.expect("failed to connect to zbus");
loop {
sleep(Duration::from_secs(1)).await;
let media_players = MediaPlayer::new_all(&connection)
.await
.expect("failed to get media players");
}
}