tree: b91716d23fa8c7f9a5d5f544e5233fc24d2a292e [path history] [tgz]
  1. BUILD.gn
  2. README.md
  3. discovery.fidl
  4. fuchsia.media.sessions2.api
  5. images.fidl
  6. player.fidl
  7. publisher.fidl
sdk/fidl/fuchsia.media.sessions2/README.md

Media Session Service

Fuchsia's Media Session Service mediates access between media players which choose to publish “media sessions” (from here on referred to as “sessions”) and other components of the system which want to observe or control those sessions, such as a “Now Playing” UI, a remote control, or a system media policy enforcer.

Rendered Docs

  • FIDL
  • Dart // TODO(turnage): Add link when Fuchsia dart docs come up.
  • Rust

Overview

A system service, the media session registry service (here on, Registry Service), exposes two FIDL protocols: Publisher and Discovery.

Media players publish themselves over the Publisher protocol. Clients interested in discovering ongoing media sessions on the system do so through the Discovery protocol.

Overview

          |        Registry Service       |
          |===============================|

Players ----> | Publisher | | | | | | Discovery | <---- “Now Playing” UI, etc |===============================|

Example Use Case: A “Now Playing” UI

A client can watch for updates to all sessions using Discovery.WatchSessions.

let discovery_proxy = connect_to_service::<DiscoveryMarker>()?;
let (session_watcher, session_watcher_request) = create_endpoints()?;
let session_watcher_proxy = session_watcher.into_proxy()?;

let watcher = discovery_proxy.watch_sessions(
    WatchOptions::default(),
    session_watcher_request)?;

loop {
    let sessions_reply_future = session_watcher_proxy.watch_sessions()?;
    let sessions = await!(sessions_reply_future)?;
    for session in sessions {
        update_ui_for_session_with_id(
            session.id,
            session.player_status,
            session.media_images,
            session.metadata,
            ...);
    }
}

Publishing a Player

Players must implement Player and publish themselves once with Publisher.Publish.

let (player_client_end, player_server_end) = create_endpoints()?;
let publisher_proxy = connect_to_service::<PublisherMarker>()?;

spawn_implementation_to_serve(player_server_end);

publisher_proxy.publish(player_client_end, PlayerRegistration {
    domain: Some(PLAYER_DOMAIN),
});