1

ビデオを正常に再生している AVPlayer オブジェクトがありますが、

- (void)playerItemDidReachEnd:(NSNotification *)notification

メソッドが呼び出されることはありません。Appleのドキュメントに正確に従ったため、何が間違っているのかわかりません。これが私のコードです:

           self.playerItem = [AVPlayerItem playerItemWithAsset:asset];
           [self.playerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext];//This works okay
         self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
         [[NSNotificationCenter defaultCenter] addObserver:self
                                                  selector:@selector(playerItemDidReachEnd:)
                                                      name:AVPlayerItemDidPlayToEndTimeNotification
                                                    object:self.playerItem];
         self.player = [AVPlayer playerWithPlayerItem:self.playerItem];

         self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];

                        [self.playerLayer setFrame:[[[self playerView] layer] bounds]];
                        self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
                        [self.playerLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
                        [self.playerLayer setHidden:NO];
                        [[[self playerView] layer] addSublayer:self.playerLayer];
4

1 に答える 1