I use AVPlayer to play an online movie. It is working fine. Now the problem is that when I exit the view before the movie starts playing, the background process continues to work. And when the movie loads, it starts playing in the background.
I tried to release the player in viewWillDisappear. But it does not work.
- (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 anybody help? thanks in advance
source share