MPMoviePlayerController.Notifications.ObservePlaybackDidFinish Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Sobrecargas
ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>) |
Notificação fortemente tipada para a PlaybackDidFinishNotification constante. |
ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>) |
Notificação fortemente tipada para a PlaybackDidFinishNotification constante. |
ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>)
Notificação fortemente tipada para a PlaybackDidFinishNotification constante.
public static Foundation.NSObject ObservePlaybackDidFinish (Foundation.NSObject objectToObserve, EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> handler);
static member ObservePlaybackDidFinish : Foundation.NSObject * EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> -> Foundation.NSObject
Parâmetros
- objectToObserve
- NSObject
O objeto a ser observado.
Método a ser invocado quando a notificação é postada.
Retornos
Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)
Comentários
Esse método pode ser usado para assinar PlaybackDidFinishNotification notificações.
// 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 ();
Aplica-se a
ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>)
Notificação fortemente tipada para a PlaybackDidFinishNotification constante.
public static Foundation.NSObject ObservePlaybackDidFinish (EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> handler);
static member ObservePlaybackDidFinish : EventHandler<MediaPlayer.MPMoviePlayerFinishedEventArgs> -> Foundation.NSObject
Parâmetros
Método a ser invocado quando a notificação é postada.
Retornos
Objeto de token que pode ser usado para parar de receber notificações descartando-o ou passando-o para RemoveObservers(IEnumerable<NSObject>)
Comentários
O exemplo a seguir mostra como os desenvolvedores podem usar esse método em seu código:
//
// 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 ();
}