Remove observer only if it has been registered

Happens if someone creates Video component, but doesn't set src to it.
This commit is contained in:
Stanisław Chmiela 2016-05-17 09:40:58 +02:00
parent 88e47159d7
commit e7337227fe

View File

@ -675,8 +675,10 @@ static NSString *const playbackRate = @"rate";
- (void)removeFromSuperview - (void)removeFromSuperview
{ {
[_player pause]; [_player pause];
if (_playbackRateObserverRegistered) {
[_player removeObserver:self forKeyPath:playbackRate]; [_player removeObserver:self forKeyPath:playbackRate];
_playbackRateObserverRegistered = NO; _playbackRateObserverRegistered = NO;
}
_player = nil; _player = nil;
[self removePlayerLayer]; [self removePlayerLayer];