MPMoviePlayerController.Notifications.ObservePlaybackDidFinish Méthode

Définition

Surcharges

ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>)

Notification fortement typée pour la PlaybackDidFinishNotification constante.

ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>)

Notification fortement typée pour la PlaybackDidFinishNotification constante.

ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>)

Notification fortement typée pour la PlaybackDidFinishNotification constante.

public static Foundation.NSObject ObservePlaybackDidFinish (Foundation.NSObject objectToObserve, EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> handler);
static member ObservePlaybackDidFinish : Foundation.NSObject * EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> -> Foundation.NSObject

Paramètres

objectToObserve
NSObject

Objet à observer.

handler
EventHandler<MPMoviePlayerFinishedEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

Cette méthode peut être utilisée pour PlaybackDidFinishNotification s’abonner aux notifications.

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

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

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

S’applique à

ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>)

Notification fortement typée pour la PlaybackDidFinishNotification constante.

public static Foundation.NSObject ObservePlaybackDidFinish (EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> handler);
static member ObservePlaybackDidFinish : EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> -> Foundation.NSObject

Paramètres

handler
EventHandler<MPMoviePlayerFinishedEventArgs>

Méthode à appeler lors de la publication de la notification.

Retours

Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)

Remarques

L’exemple suivant montre comment les développeurs peuvent utiliser cette méthode dans leur code :

//
// Lambda style
//

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

    Console.WriteLine ("FinishReason", args.FinishReason);
});

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

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

    Console.WriteLine ("FinishReason", args.FinishReason);
}

void Setup ()
{
    notification = MPMoviePlayerController.Notifications.ObservePlaybackDidFinish (Callback);
}

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

S’applique à