0

我的代码:

    NSURL *videoURL = [NSURL URLWithString:strVideo];

    playerController = [[AVPlayerViewController alloc]init];

    playerController.player = [AVPlayer playerWithURL:videoURL];


    playerController.view.frame = self.view.frame;

    playerController.player.currentItem.forwardPlaybackEndTime = CMTimeMake(timeDuration, 1);

    [playerController.player play];


    playerController.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;


    [self presentViewController:playerController animated:YES completion:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerItemDidReachEnd:)
                                                 name:AVPlayerItemDidPlayToEndTimeNotification
                                               object:[playerController.player currentItem]];


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

    [playerController dismissViewControllerAnimated:YES completion:nil];


    NSLog(@"IT REACHED THE END");

  }

这里playerItemDidReachEnd调用但avplayercontroller不解雇。

4

1 回答 1

0

我认为你必须删除下面的代码行,

playerController.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

它可能不会调用您的 Notification 方法。只需删除代码并尝试一下。

于 2016-06-29T13:04:24.497 回答