pub async fn monitor_media_buttons(
    service_context_handle: Arc<ServiceContext>,
    sender: futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>,
) -> Result<(), Error> {
    let presenter_service =
        service_context_handle.connect::<DeviceListenerRegistryMarker>().await?;
    let (client_end, mut stream) = create_request_stream::<MediaButtonsListenerMarker>().unwrap();

    if call!(presenter_service => register_media_buttons_listener(client_end)).is_err() {
        fx_log_err!("Registering media button listener with presenter service failed.");
        return Err(format_err!("presenter service not ready"));
    }

    fasync::Task::spawn(async move {
        while let Some(Ok(media_request)) = stream.next().await {
            // Support future expansion of FIDL
            #[allow(clippy::single_match)]
            #[allow(unreachable_patterns)]
            match media_request {
                MediaButtonsListenerRequest::OnMediaButtonsEvent { event, control_handle: _ } => {
                    sender
                        .unbounded_send(event)
                        .expect("Media buttons sender failed to send event");
                }
                _ => {}
            }
        }
    })
    .detach();

    Ok(())
}
/// Method for listening to media button changes. Changes will be reported back
/// on the supplied sender.
Method for listening to media button changes. Changes will be reported back
on the supplied sender.
Method for listening to media button changes . Changes will be reported back on the supplied sender .
pub async fn monitor_media_buttons(
    service_context_handle: Arc<ServiceContext>,
    sender: futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>,
) -> Result<(), Error> {
    let presenter_service =
        service_context_handle.connect::<DeviceListenerRegistryMarker>().await?;
    let (client_end, mut stream) = create_request_stream::<MediaButtonsListenerMarker>().unwrap();
    if call!(presenter_service => register_media_buttons_listener(client_end)).is_err() {
        fx_log_err!("Registering media button listener with presenter service failed.");
        return Err(format_err!("presenter service not ready"));
    }
    fasync::Task::spawn(async move {
        while let Some(Ok(media_request)) = stream.next().await {
            // Support future expansion of FIDL
            #[allow(clippy::single_match)]
            #[allow(unreachable_patterns)]
            match media_request {
                MediaButtonsListenerRequest::OnMediaButtonsEvent { event, control_handle: _ } => {
                    sender
                        .unbounded_send(event)
                        .expect("Media buttons sender failed to send event");
                }
                _ => {}
            }
        }
    })
    .detach();
    Ok(())
}
pub async fn monitor_media_buttons ( service_context_handle : Arc < ServiceContext > , sender : futures :: channel :: mpsc :: UnboundedSender < MediaButtonsEvent > , ) -> Result < ( ) , Error > { let presenter_service = service_context_handle . connect :: < DeviceListenerRegistryMarker > ( ) . await ? ; let ( client_end , mut stream ) = create_request_stream :: < MediaButtonsListenerMarker > ( ) . unwrap ( ) ; if call ! ( presenter_service register_media_buttons_listener ( client_end ) ) . is_err ( ) { fx_log_err ! ( " " ) ; return Err ( format_err ! ( " " ) ) ; } fasync :: Task :: spawn ( async move { while let Some ( Ok ( media_request ) ) = stream . next ( ) . await { // Support future expansion of FIDL # [ allow ( clippy single_match ) ] # [ allow ( unreachable_patterns ) ] match media_request { MediaButtonsListenerRequest :: OnMediaButtonsEvent { event , control_handle : _ } => { sender . unbounded_send ( event ) . expect ( " " ) ; } _ => { } } } } ) . detach ( ) ; Ok ( ( ) ) }
Method for listening to media button changes.
Method for listening to media button changes .
service_context_handle
Arc<ServiceContext>
sender
futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>
service_context_handle
Arc<ServiceContext>
sender
futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>