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