【发布时间】:2016-05-10 08:33:02
【问题描述】:
我有表格视图,其中包含从 Parse 加载视频对象的单元格。 加载视频时,播放按钮会出现在视频的静止图像表示上。播放按钮是故事板 UIButton 的出口。
在我的 FeedCell.m 中:
- (IBAction)playButtonTapped:(id)sender {
[self.player play];
if (self.player.rate != 0 && (self.player.error == nil)) {
// player is playing
self.playButton.hidden = YES;
}
self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector (playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[self.player currentItem]];
}
- (void)playerItemDidReachEnd:(NSNotification *)notification {
self.playButton.hidden = NO;
[self.playerItem seekToTime:kCMTimeZero];
[self.player pause];
}
我想添加此按钮的功能,以便在点击 playButton 时播放 AVPlayerItem 并暂停所有其他 AVPlayer 实例。
我可以通过设置另一个 NSNotification 来做到这一点吗?
【问题讨论】:
标签: ios objective-c uibutton storyboard avplayer