mirror of
				https://github.com/talwat/lowfi
				synced 2025-10-31 11:18:49 +00:00 
			
		
		
		
	fix: show volume bar (mpris) (#59)
This commit is contained in:
		
							parent
							
								
									2b20bf7709
								
							
						
					
					
						commit
						67a4c4f0ea
					
				| @ -11,6 +11,8 @@ use tokio::sync::mpsc::Sender; | ||||
| 
 | ||||
| use super::Messages; | ||||
| 
 | ||||
| use super::ui::audio_bar_flash; | ||||
| 
 | ||||
| const ERROR: fdo::Error = fdo::Error::Failed(String::new()); | ||||
| 
 | ||||
| /// The actual MPRIS player.
 | ||||
| @ -188,6 +190,8 @@ impl PlayerInterface for Player { | ||||
|     async fn set_volume(&self, volume: Volume) -> Result<()> { | ||||
|         self.player.set_volume(volume as f32); | ||||
| 
 | ||||
|         audio_bar_flash(); | ||||
| 
 | ||||
|         Ok(()) | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -48,6 +48,10 @@ lazy_static! { | ||||
|     static ref VOLUME_TIMER: AtomicUsize = AtomicUsize::new(0); | ||||
| } | ||||
| 
 | ||||
| pub fn audio_bar_flash() { | ||||
|     VOLUME_TIMER.store(1, Ordering::Relaxed); | ||||
| } | ||||
| 
 | ||||
| /// Represents an abstraction for drawing the actual lowfi window itself.
 | ||||
| ///
 | ||||
| /// The main purpose of this struct is just to add the fancy border,
 | ||||
|  | ||||
| @ -1,15 +1,13 @@ | ||||
| //! Responsible for specifically recieving terminal input
 | ||||
| //! using [`crossterm`].
 | ||||
| 
 | ||||
| use std::sync::atomic::Ordering; | ||||
| 
 | ||||
| use crossterm::event::{self, EventStream, KeyCode, KeyEventKind, KeyModifiers}; | ||||
| use futures::{FutureExt, StreamExt}; | ||||
| use tokio::sync::mpsc::Sender; | ||||
| 
 | ||||
| use crate::player::Messages; | ||||
| 
 | ||||
| use super::VOLUME_TIMER; | ||||
| use super::audio_bar_flash; | ||||
| 
 | ||||
| /// Starts the listener to recieve input from the terminal for various events.
 | ||||
| pub async fn listen(sender: Sender<Messages>) -> eyre::Result<()> { | ||||
| @ -64,10 +62,10 @@ pub async fn listen(sender: Sender<Messages>) -> eyre::Result<()> { | ||||
|             _ => continue, | ||||
|         }; | ||||
| 
 | ||||
|         // If it's modifying the volume, then we'll set the `VOLUME_TIMER` to 1
 | ||||
|         // 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 { | ||||
|             VOLUME_TIMER.store(1, Ordering::Relaxed); | ||||
|             audio_bar_flash(); | ||||
|         } | ||||
| 
 | ||||
|         sender.send(messages).await?; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user