Fixes #963
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:
parent
737d348ff0
commit
28bae40c6c
@ -140,8 +140,8 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
[self removePlayerItemObservers];
|
|
||||||
[self removePlayerLayer];
|
[self removePlayerLayer];
|
||||||
|
[self removePlayerItemObservers];
|
||||||
[_player removeObserver:self forKeyPath:playbackRate context:nil];
|
[_player removeObserver:self forKeyPath:playbackRate context:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,9 +252,6 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
* observer set */
|
* observer set */
|
||||||
- (void)removePlayerItemObservers
|
- (void)removePlayerItemObservers
|
||||||
{
|
{
|
||||||
if (_playerLayer) {
|
|
||||||
[_playerLayer removeObserver:self forKeyPath:readyForDisplayKeyPath];
|
|
||||||
}
|
|
||||||
if (_playerItemObserversSet) {
|
if (_playerItemObserversSet) {
|
||||||
[_playerItem removeObserver:self forKeyPath:statusKeyPath];
|
[_playerItem removeObserver:self forKeyPath:statusKeyPath];
|
||||||
[_playerItem removeObserver:self forKeyPath:playbackBufferEmptyKeyPath];
|
[_playerItem removeObserver:self forKeyPath:playbackBufferEmptyKeyPath];
|
||||||
@ -268,13 +265,13 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
|
|
||||||
- (void)setSrc:(NSDictionary *)source
|
- (void)setSrc:(NSDictionary *)source
|
||||||
{
|
{
|
||||||
|
[self removePlayerLayer];
|
||||||
[self removePlayerTimeObserver];
|
[self removePlayerTimeObserver];
|
||||||
[self removePlayerItemObservers];
|
[self removePlayerItemObservers];
|
||||||
_playerItem = [self playerItemForSource:source];
|
_playerItem = [self playerItemForSource:source];
|
||||||
[self addPlayerItemObservers];
|
[self addPlayerItemObservers];
|
||||||
|
|
||||||
[_player pause];
|
[_player pause];
|
||||||
[self removePlayerLayer];
|
|
||||||
[_playerViewController.view removeFromSuperview];
|
[_playerViewController.view removeFromSuperview];
|
||||||
_playerViewController = nil;
|
_playerViewController = nil;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user