簡體   English   中英

iOS 7通知中心未調用

[英]iOS 7 Notification center not called

我已經使用此代碼來播放一些視頻。 並希望在比賽結束時收到事件。 但無法使用通知中心獲取事件。

我已經嘗試過此代碼

    NSString * str=[[NSBundle mainBundle]pathForResource:@"iGreet" ofType:@"m4v"];

    NSURL * url=[NSURL fileURLWithPath:str];

    MPMoviePlayerController * movieController=[[MPMoviePlayerController alloc]initWithContentURL:url];
    movieController.controlStyle=MPMovieControlStyleFullscreen;
    [movieController.view setFrame:self.view.bounds];

    [movieController setMovieSourceType:MPMovieSourceTypeFile];
    movieController.shouldAutoplay=YES;

    [self.view addSubview:movieController.view];
    [movieController setFullscreen:YES animated:YES];
    [movieController play];


    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onStop:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:movieController];

}

  -(void)onStop:(NSNotification*)notification
{


}

改成:

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onStop:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:movieController];

-(void)onStop:(NSNotification*)notification
{


}

這個對我有用。

這來自MPMoviePlayerController的文檔

當電影以全屏模式顯示並且用戶點擊“完成”時,不會發送此通知。 “完成”按鈕暫停播放,並使電影播放器​​退出全屏模式。 要檢測這種情況,請注冊其他通知,例如MPMoviePlayerDidExitFullscreenNotification。

也許這可能對您有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM