docs(internal): add internal documentation for ui::flash_audio()

This commit is contained in:
talwat 2025-02-19 23:48:31 +02:00
parent 67a4c4f0ea
commit 503b4fe9db
3 changed files with 12 additions and 12 deletions

View File

@ -9,10 +9,9 @@ use mpris_server::{
};
use tokio::sync::mpsc::Sender;
use super::ui;
use super::Messages;
use super::ui::audio_bar_flash;
const ERROR: fdo::Error = fdo::Error::Failed(String::new());
/// The actual MPRIS player.
@ -169,7 +168,10 @@ impl PlayerInterface for Player {
.load()
.as_ref()
.map_or_else(Metadata::new, |track| {
let mut metadata = Metadata::builder().title(track.name.clone()).album(self.player.list.name.clone()).build();
let mut metadata = Metadata::builder()
.title(track.name.clone())
.album(self.player.list.name.clone())
.build();
metadata.set_length(
track
@ -189,8 +191,7 @@ impl PlayerInterface for Player {
async fn set_volume(&self, volume: Volume) -> Result<()> {
self.player.set_volume(volume as f32);
audio_bar_flash();
ui::flash_audio();
Ok(())
}

View File

@ -48,7 +48,10 @@ lazy_static! {
static ref VOLUME_TIMER: AtomicUsize = AtomicUsize::new(0);
}
pub fn audio_bar_flash() {
/// Sets the volume timer to one, effectively flashing the audio display in lowfi's UI.
///
/// The amount of frames the audio display is visible for is determined by [AUDIO_BAR_DURATION].
pub fn flash_audio() {
VOLUME_TIMER.store(1, Ordering::Relaxed);
}

View File

@ -5,9 +5,7 @@ use crossterm::event::{self, EventStream, KeyCode, KeyEventKind, KeyModifiers};
use futures::{FutureExt, StreamExt};
use tokio::sync::mpsc::Sender;
use crate::player::Messages;
use super::audio_bar_flash;
use crate::player::{ui, Messages};
/// Starts the listener to recieve input from the terminal for various events.
pub async fn listen(sender: Sender<Messages>) -> eyre::Result<()> {
@ -62,10 +60,8 @@ pub async fn listen(sender: Sender<Messages>) -> eyre::Result<()> {
_ => continue,
};
// If it's modifying the volume, then we'll call audio_bar_flash func
// so that the UI thread will know that it should show the audio bar.
if let Messages::ChangeVolume(_) = messages {
audio_bar_flash();
ui::flash_audio();
}
sender.send(messages).await?;