pub struct NowPlayingJXA { /* private fields */ }Implementations§
Source§impl NowPlayingJXA
impl NowPlayingJXA
Sourcepub fn new(update_interval: Duration) -> Self
pub fn new(update_interval: Duration) -> Self
Creates a new instance of NowPlayingJXA and registers for playback notifications.
This function initializes a new NowPlayingJXA object, sets up necessary observers,
and ensures that media metadata is updated upon creation.
§Returns
NowPlayingJXA: A new instance of theNowPlayingJXAstruct.
§Example
use media_remote::NowPlayingJXA;
use std::time::Duration;
let now_playing = NowPlayingJXA::new(Duration::from_secs(3));Sourcepub fn get_info(&self) -> RwLockReadGuard<'_, Option<NowPlayingInfo>>
pub fn get_info(&self) -> RwLockReadGuard<'_, Option<NowPlayingInfo>>
Retrieves the latest now playing information.
This function provides a read-locked view of the current playing media metadata.
§Note
- The lock should be released as soon as possible to minimize blocking time.
§Returns
RwLockReadGuard<'_, Option<NowPlayingInfo>>: A guard to the now playing metadata.
§Example
use media_remote::NowPlayingJXA;
use std::time::Duration;
let now_playing = NowPlayingJXA::new(Duration::from_secs(3));
let guard = now_playing.get_info();
let info = guard.as_ref();
if let Some(info) = info {
println!("Currently playing: {:?}", info.title);
}
drop(guard);Trait Implementations§
Source§impl Controller for NowPlayingJXA
impl Controller for NowPlayingJXA
fn is_info_some(&self) -> bool
Source§impl Drop for NowPlayingJXA
impl Drop for NowPlayingJXA
Source§impl Subscription for NowPlayingJXA
impl Subscription for NowPlayingJXA
fn get_info(&self) -> RwLockReadGuard<'_, Option<NowPlayingInfo>>
fn get_token_counter(&self) -> Arc<AtomicU64>
fn get_listeners( &self, ) -> Arc<Mutex<HashMap<ListenerToken, Box<dyn Fn(RwLockReadGuard<'_, Option<NowPlayingInfo>>) + Send + Sync>>>>
Source§fn subscribe<F: Fn(RwLockReadGuard<'_, Option<NowPlayingInfo>>) + Send + Sync + 'static>(
&self,
listener: F,
) -> ListenerToken
fn subscribe<F: Fn(RwLockReadGuard<'_, Option<NowPlayingInfo>>) + Send + Sync + 'static>( &self, listener: F, ) -> ListenerToken
Subscribes a listener to receive updates when the “Now Playing” information changes. Read more
Source§fn unsubscribe(&self, token: ListenerToken)
fn unsubscribe(&self, token: ListenerToken)
Unsubscribes a previously registered listener using the provided
ListenerToken. Read moreAuto Trait Implementations§
impl Freeze for NowPlayingJXA
impl !RefUnwindSafe for NowPlayingJXA
impl Send for NowPlayingJXA
impl Sync for NowPlayingJXA
impl Unpin for NowPlayingJXA
impl !UnwindSafe for NowPlayingJXA
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more