我需要一些代码来捕获"完成" iOS中的AVPlayer按钮单击事件。我可以使用以下代码获得播放/暂停事件
-(IBAction)play_pressed:(id)sender{
NSURL *videoURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
self.player = [AVPlayer playerWithURL:videoURL];
self.avPlayerViewcontroller = [AVPlayerViewController new];
self.avPlayerViewcontroller.player = self.player;
self.avPlayerViewcontroller.view.frame = self.view.frame;
[self.player addObserver:self forKeyPath:@"rate" options:0 context:nil];
[self presentViewController:self.avPlayerViewcontroller animated:YES completion:nil];
[self.player play];}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"rate"]) {
if ([self.player rate]) {
NSLog(@"Playing");
}
else {
NSLog(@"Paused");
}
}