Bug happens when uri is changed for a video.

The fix:
Remove player layer before addPlayerItemObservers so _playerItemObserversSet is still set to NO if observers have already been removed.
This commit is contained in:
seansy 2018-03-19 12:56:55 -07:00 committed by Sean Holbert
parent 737d348ff0
commit 28bae40c6c

View File

@ -140,8 +140,8 @@ static NSString *const timedMetadata = @"timedMetadata";
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self removePlayerItemObservers];
[self removePlayerLayer];
[self removePlayerItemObservers];
[_player removeObserver:self forKeyPath:playbackRate context:nil];
}
@ -252,9 +252,6 @@ static NSString *const timedMetadata = @"timedMetadata";
* observer set */
- (void)removePlayerItemObservers
{
if (_playerLayer) {
[_playerLayer removeObserver:self forKeyPath:readyForDisplayKeyPath];
}
if (_playerItemObserversSet) {
[_playerItem removeObserver:self forKeyPath:statusKeyPath];
[_playerItem removeObserver:self forKeyPath:playbackBufferEmptyKeyPath];
@ -268,13 +265,13 @@ static NSString *const timedMetadata = @"timedMetadata";
- (void)setSrc:(NSDictionary *)source
{
[self removePlayerLayer];
[self removePlayerTimeObserver];
[self removePlayerItemObservers];
_playerItem = [self playerItemForSource:source];
[self addPlayerItemObservers];
[_player pause];
[self removePlayerLayer];
[_playerViewController.view removeFromSuperview];
_playerViewController = nil;