はい。プレーヤーのステータスまたはレートに KVO オブザーバーを追加します。
- (IBAction)go {
self.player = .....
self.player.actionAtItemEnd = AVPlayerActionStop;
[self.player addObserver:self forKeyPath:@"rate" options:0 context:0];
}
- (void)stopped {
...
[self.player removeObserver:self]; //assumes we are the only observer
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (context == 0) {
if(player.rate==0.0) //stopped
[self stopped];
}
else
[super observeVal...];
}
基本的にはそれだけです。
免責事項:ここに書いたので、コードが正しいかどうかは確認していません。また、これまでAVPlayerを使用したことはありませんが、ほぼ正しいはずです。