共用方式為


MPMoviePlayerController.PlaybackDidFinishNotification 屬性

定義

PlaybackDidFinish 的通知常數

[Foundation.Advice("Use MPMoviePlayerController.Notifications.ObservePlaybackDidFinish helper method instead.")]
[Foundation.Field("MPMoviePlayerPlaybackDidFinishNotification", "MediaPlayer")]
[ObjCRuntime.Deprecated(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, "Use 'AVPlayerViewController' (AVKit) instead.")]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.WatchOS, ObjCRuntime.PlatformArchitecture.All, null)]
public static Foundation.NSString PlaybackDidFinishNotification { [ObjCRuntime.Deprecated(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, "Use 'AVPlayerViewController' (AVKit) instead.")] [ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.WatchOS, ObjCRuntime.PlatformArchitecture.All, null)] get; }
member this.PlaybackDidFinishNotification : Foundation.NSString

屬性值

NSString 常數應該用來做為 NSNotificationCenter 的權杖。

屬性

備註

這個常數可以搭配 使用 NSNotificationCenter ,以註冊此通知的接聽程式。 這是 NSString 而非字串,因為這些值可以當做某些原生程式庫中的權杖使用,而不是單純用於其實際字串內容。 回呼的 'notification' 參數包含通知類型特有的額外資訊。

若要訂閱此通知,開發人員可以使用方便 MPMoviePlayerController.Notifications 的 。 ObservePlaybackDidFinish 方法可提供通知參數的強型別存取。

下列範例示範如何使用強型別的 Notifications 類別,來排除通知中可用屬性的猜測:

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

下列範例示範如何搭配 DefaultCenter API 使用通知:

// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
        MPMoviePlayerController.PlaybackDidFinishNotification, (notification) => {Console.WriteLine ("Received the notification MPMoviePlayerController", notification); }


// Method style
void Callback (NSNotification notification)
{
    Console.WriteLine ("Received a notification MPMoviePlayerController", notification);
}

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (MPMoviePlayerController.PlaybackDidFinishNotification, Callback);
}

適用於