AVPlayer 一直在后台运行
我正在使用 AVPlayer 播放在线电影。它运行良好。现在的问题是,当我在电影开始播放之前从视图中弹出时,后台进程会继续运行。当电影加载后,它开始在后台播放。
我尝试在 viewWillDisappear 中释放播放器。但它不起作用。
- (void)viewWillDisappear:(BOOL)animated
{
if (self.player.currentItem.status != AVPlayerItemStatusReadyToPlay)
{
[self.player.currentItem removeObserver:self forKeyPath:kRateKey];
[self.player.currentItem removeObserver:self forKeyPath:kStatusKey];
[self.player.currentItem removeObserver:self forKeyPath:kTimedMetadataKey];
}
[self.player pause];
[self.player release];
[self.playerLayerView release];
[super viewWillDisappear:animated];
}
有人可以帮忙吗? 提前致谢
I am using AVPlayer to play online movie. It is working fine. Now the problem is, when I pop out from the view before the movie starts playing, the background process keeps running. And when the movie gets loaded, it starts playing in background.
I tried to release the player in viewWillDisappear. But its not working.
- (void)viewWillDisappear:(BOOL)animated
{
if (self.player.currentItem.status != AVPlayerItemStatusReadyToPlay)
{
[self.player.currentItem removeObserver:self forKeyPath:kRateKey];
[self.player.currentItem removeObserver:self forKeyPath:kStatusKey];
[self.player.currentItem removeObserver:self forKeyPath:kTimedMetadataKey];
}
[self.player pause];
[self.player release];
[self.playerLayerView release];
[super viewWillDisappear:animated];
}
Can anyone please help?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能会有所帮助..
This might help..