1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use ;
use RcBlock;
use ImageReader;
use ;
use NSWorkspace;
use ;
use crate::;
// Retrieves information about an application based on its bundle identifier.
///
///
/// If the application is found, its name and icon are returned as a `BundleInfo` struct.
/// Otherwise, `None` is returned if the application cannot be located or an error occurs
/// during data retrieval.
///
/// # Arguments
/// - `id`: A string slice representing the application's bundle identifier.
///
/// # Returns
/// - `Option<BundleInfo>`:
/// - `Some(BundleInfo)` containing the application's name and icon if retrieval is successful.
/// - `None` if the application cannot be found or if an error occurs during processing.
///
/// # Example
/// ```rust
/// use media_remote::{get_now_playing_client_parent_app_bundle_identifier, get_bundle_info};
///
/// let bundle_id = get_now_playing_client_parent_app_bundle_identifier();
///
/// if let Some(id) = bundle_id {
/// if let Some(bundle) = get_bundle_info(id.as_str()) {
/// println!("App Name: {}", bundle.name);
/// } else {
/// println!("Application not found.");
/// }
/// }
/// ```
/// Adds an observer for a specific media notification.
///
/// This function registers a closure to be executed when the specified `notification`
/// is posted. It listens for notifications related to media playback state changes.
///
/// **Note:** [`register_for_now_playing_notifications`] **must** be called before using
/// this function to ensure notifications are received.
///
/// # Arguments
/// - `notification`: The [`Notification`] type representing the event to observe.
/// - `closure`: A closure to execute when the notification is received.
///
/// # Returns
/// - An [`Observer`] handle that can be used to remove the observer later.
///
/// # Example
/// ```rust
/// use media_remote::{register_for_now_playing_notifications, add_observer, Notification};
///
/// register_for_now_playing_notifications();
///
/// let observer = add_observer(Notification::NowPlayingApplicationIsPlayingDidChange, || {
/// println!("Now playing status changed.");
/// });
/// ```
/// Removes a previously added observer.
///
/// This function removes an observer registered with [`add_observer`], preventing further
/// notifications from being received.
///
/// # Arguments
/// - `observer`: The [`Observer`] handle returned from [`add_observer`].
///
/// # Example
/// ```rust
/// use media_remote::{register_for_now_playing_notifications, add_observer, remove_observer, Notification};
///
/// register_for_now_playing_notifications();
///
/// let observer = add_observer(Notification::NowPlayingApplicationIsPlayingDidChange, || {
/// println!("Now playing status changed.");
/// });
///
/// // Later, when no longer needed:
/// remove_observer(observer);
/// ```