added removePlayerLayer to fix iOS crash (#650)

This commit is contained in:
Zach Nolan 2017-06-09 14:31:46 -07:00 committed by Matt Apperson
parent 72a46bc308
commit ef2120b418

View File

@ -141,6 +141,7 @@ static NSString *const timedMetadata = @"timedMetadata";
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[self removePlayerItemObservers]; [self removePlayerItemObservers];
[self removePlayerLayer];
[_player removeObserver:self forKeyPath:playbackRate context:nil]; [_player removeObserver:self forKeyPath:playbackRate context:nil];
} }
@ -327,23 +328,23 @@ static NSString *const timedMetadata = @"timedMetadata";
if ([keyPath isEqualToString: timedMetadata]) if ([keyPath isEqualToString: timedMetadata])
{ {
NSArray<AVMetadataItem *> *items = [change objectForKey:@"new"]; NSArray<AVMetadataItem *> *items = [change objectForKey:@"new"];
if (items && ![items isEqual:[NSNull null]] && items.count > 0) { if (items && ![items isEqual:[NSNull null]] && items.count > 0) {
NSMutableArray *array = [NSMutableArray new]; NSMutableArray *array = [NSMutableArray new];
for (AVMetadataItem *item in items) { for (AVMetadataItem *item in items) {
NSString *value = item.value; NSString *value = item.value;
NSString *identifier = item.identifier; NSString *identifier = item.identifier;
if (![value isEqual: [NSNull null]]) { if (![value isEqual: [NSNull null]]) {
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects:@[value, identifier] forKeys:@[@"value", @"identifier"]]; NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects:@[value, identifier] forKeys:@[@"value", @"identifier"]];
[array addObject:dictionary]; [array addObject:dictionary];
} }
} }
self.onTimedMetadata(@{ self.onTimedMetadata(@{
@"target": self.reactTag, @"target": self.reactTag,
@"metadata": array @"metadata": array