AVPlayerItemDidPlayToEndTimeNotification无法正常工作

时间:2017-11-09 18:56:56

标签: ios objective-c avplayer nsnotificationcenter

  NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"thoughtcastAnimate_v02" withExtension:@"mov"];



    // create an AVPlayer
    AVPlayer *player = [AVPlayer playerWithURL:videoURL];

    // create a player view controller
    AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];

    controller.showsPlaybackControls = false;


    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying) name:AVPlayerItemDidPlayToEndTimeNotification object: player];//edited

    controller.player = player;
    // show the view controller
    [self addChildViewController:controller];
    [self.view addSubview:controller.view];
    controller.view.frame = self.view.frame;

    [player play];

itemDidFinishPlaying永远不会被调用?!

我不明白为什么。 也许我的NSNotificationCenter问题无效。或者也许是其中一个参数。不确定。

0 个答案:

没有答案