Compartir a través de


AVPlayerItem.Notifications.ObserveDidPlayToEndTime Método

Definición

Sobrecargas

ObserveDidPlayToEndTime(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la DidPlayToEndTimeNotification constante.

ObserveDidPlayToEndTime(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la DidPlayToEndTimeNotification constante.

ObserveDidPlayToEndTime(EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la DidPlayToEndTimeNotification constante.

public static Foundation.NSObject ObserveDidPlayToEndTime (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidPlayToEndTime : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

handler
EventHandler<NSNotificationEventArgs>

Método para invocar cuando se publica la notificación.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

En el ejemplo siguiente se muestra cómo puede usar este método en el código.

//
// Lambda style
//

// listening
notification = AVPlayerItem.Notifications.ObserveDidPlayToEndTime ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);
});

// To stop listening:
notification.Dispose ();

//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSNotificationEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);
}

void Setup ()
{
    notification = AVPlayerItem.Notifications.ObserveDidPlayToEndTime (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

Se aplica a

ObserveDidPlayToEndTime(NSObject, EventHandler<NSNotificationEventArgs>)

Notificación fuertemente tipada para la DidPlayToEndTimeNotification constante.

public static Foundation.NSObject ObserveDidPlayToEndTime (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidPlayToEndTime : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parámetros

objectToObserve
NSObject

Objeto específico que se va a observar.

handler
EventHandler<NSNotificationEventArgs>

Controlador que responde a la notificación cuando se produce.

Devoluciones

Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)

Comentarios

Este método se puede usar para suscribirse DidPlayToEndTimeNotification a las notificaciones.

// Listen to all notifications posted for any object
var token = AVPlayerItem.Notifications.ObserveDidPlayToEndTime ((notification) => {
	Console.WriteLine ("Observed DidPlayToEndTimeNotification!");
};

// Listen to all notifications posted for a single object
var token = AVPlayerItem.Notifications.ObserveDidPlayToEndTime (objectToObserve, (notification) => {
	Console.WriteLine ($"Observed DidPlayToEndTimeNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Se aplica a