MPMoviePlayerController.Notifications.ObservePlaybackDidFinish 方法

定义

重载

ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>)

常量的强类型通知 PlaybackDidFinishNotification

ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>)

常量的强类型通知 PlaybackDidFinishNotification

ObservePlaybackDidFinish(NSObject, EventHandler<MPMoviePlayerFinishedEventArgs>)

常量的强类型通知 PlaybackDidFinishNotification

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

参数

objectToObserve
NSObject

要观察的对象。

handler
EventHandler<MPMoviePlayerFinishedEventArgs>

发布通知时调用的方法。

返回

令牌对象,可用于通过释放通知或将其传递给来停止接收通知 RemoveObservers(IEnumerable<NSObject>)

注解

此方法可用于订阅 PlaybackDidFinishNotification 通知。

// 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 ();

适用于

ObservePlaybackDidFinish(EventHandler<MPMoviePlayerFinishedEventArgs>)

常量的强类型通知 PlaybackDidFinishNotification

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

参数

handler
EventHandler<MPMoviePlayerFinishedEventArgs>

发布通知时调用的方法。

返回

令牌对象,可用于通过释放通知或将其传递给来停止接收通知 RemoveObservers(IEnumerable<NSObject>)

注解

以下示例演示开发人员如何在代码中使用此方法:

//
// 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 ();
}

适用于