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
//! The OS's media keys and its "now playing", for an egui app: corundum-framework-platform's
//! [`MediaSession`], and with the `eframe` feature [`start`], which makes one for the app's
//! window and has each event the OS sends wake the window for a frame.
//!
//! The app reads the events at the start of its frame and tells the session what changed:
//!
//! ```no_run
//! use corundum_framework_gui::media_session::{self, MediaEvent, MediaSession, MediaSessionSpec};
//! use corundum_framework_gui::{eframe, egui};
//!
//! struct Player {
//! session: MediaSession,
//! playing: bool,
//! }
//!
//! impl Player {
//! fn new(cc: &eframe::CreationContext<'_>) -> Player {
//! let spec = MediaSessionSpec { id: "net.example.Player", name: "Player", desktop_entry: None };
//! // Without a session (no session bus, say), the player still plays.
//! let session = media_session::start(cc, &spec).unwrap_or_else(|_| MediaSession::disconnected());
//! Player { session, playing: false }
//! }
//! }
//!
//! impl eframe::App for Player {
//! fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
//! while let Some(event) = self.session.poll() {
//! if event == MediaEvent::Toggle {
//! self.playing = !self.playing;
//! }
//! }
//! }
//! }
//! ```
pub use *;
/// A media session for the window `cc` makes, which repaints the window when the OS sends an
/// event, so that the app reads it within a frame even when idle.