gpt4 book ai didi

ios8 - AVPlayerItemDidPlayToEndTimeNotification 未被 iOS 8 调用

转载 作者:行者123 更新时间:2023-12-05 00:24:18 24 4
gpt4 key购买 nike

AVPlayerItem *currentItem = self.player.currentItem;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:currentItem];

我有上述通知设置。当我使用 iOS 7 运行测试时,它被奇妙地调用,但是,当我使用 iOS 8 运行我的应用程序时,它永远不会被调用。

最佳答案

它通过将观察者注册到速率键路径来解决。

[self.player addObserver:self forKeyPath:@"rate" options:0 context:nil];

- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context {
if (self.player.rate == 0.0) {
CMTime time = self.player.currentTime;
if (time >= duration) {
//song reached end
}
}

关于ios8 - AVPlayerItemDidPlayToEndTimeNotification 未被 iOS 8 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26512158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com