/// 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: ServiceContextHandle,
    sender: futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>,
) -> Result<(), Error> {
    let service_result =
        service_context_handle.lock().await.connect::<DeviceListenerRegistryMarker>().await;
    let presenter_service = match service_result {
        Ok(service) => service,
        Err(err) => {
            return Err(err);
        }
    };
    let (client_end, mut stream) = create_request_stream::<MediaButtonsListenerMarker>().unwrap();
    if 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::spawn(async move {
        while let Some(Ok(media_request)) = stream.next().await {
            // Support future expansion of FIDL
            #[allow(unreachable_patterns)]
            match media_request {
                MediaButtonsListenerRequest::OnMediaButtonsEvent { event, control_handle: _ } => {
                    sender.unbounded_send(event).ok();
                }
                _ => {}
            }
        }
    });
    return Ok(());
}
pub async fn monitor_media_buttons ( service_context_handle : ServiceContextHandle , sender : futures :: channel :: mpsc :: UnboundedSender < MediaButtonsEvent > , ) -> Result < ( ) , Error > { let service_result = service_context_handle . lock ( ) . await . connect :: < DeviceListenerRegistryMarker > ( ) . await ; let presenter_service = match service_result { Ok ( service ) => service , Err ( err ) => { return Err ( err ) ; } } ; let ( client_end , mut stream ) = create_request_stream :: < MediaButtonsListenerMarker > ( ) . unwrap ( ) ; if presenter_service . register_media_buttons_listener ( client_end ) . is_err ( ) { fx_log_err ! ( " " ) ; return Err ( format_err ! ( " " ) ) ; } fasync :: spawn ( async move { while let Some ( Ok ( media_request ) ) = stream . next ( ) . await { // Support future expansion of FIDL # [ allow ( unreachable_patterns ) ] match media_request { MediaButtonsListenerRequest :: OnMediaButtonsEvent { event , control_handle : _ } => { sender . unbounded_send ( event ) . ok ( ) ; } _ => { } } } } ) ; return Ok ( ( ) ) ; }
Method for listening to media button changes.
Method for listening to media button changes .
service_context_handle
ServiceContextHandle
sender
futures::channel::mpsc::UnboundedSender<MediaButtonsEvent>