From 5718d17f9035e20c8df0bf8b6bcb2f3aee5922d9 Mon Sep 17 00:00:00 2001 From: Joshua Sierles Date: Sat, 22 Aug 2015 21:42:26 +0200 Subject: [PATCH 1/2] switch to returning an array from customDirectEventTypes, for RN 0.10.0 compatibility --- RCTVideo.m | 12 ++++++------ RCTVideoManager.m | 30 +++++++++--------------------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/RCTVideo.m b/RCTVideo.m index 4275ab10..f0b74e25 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -101,7 +101,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" } if (_prevProgressUpdateTime == nil || (([_prevProgressUpdateTime timeIntervalSinceNow] * -1000.0) >= _progressUpdateInterval)) { - [_eventDispatcher sendInputEventWithName:RNVideoEventProgress + [_eventDispatcher sendInputEventWithName:@"onVideoProgress" body:@{@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(video.currentTime)], @"playableDuration": [self calculatePlayableDuration], @"target": self.reactTag}]; @@ -192,7 +192,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" [self.layer addSublayer:_playerLayer]; self.layer.needsDisplayOnBoundsChange = YES; - [_eventDispatcher sendInputEventWithName:RNVideoEventLoading + [_eventDispatcher sendInputEventWithName:@"onVideoLoadStart" body:@{@"src": @{ @"uri": [source objectForKey:@"uri"], @"type": [source objectForKey:@"type"], @@ -232,7 +232,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" duration = 0.0; } - [_eventDispatcher sendInputEventWithName:RNVideoEventLoaded + [_eventDispatcher sendInputEventWithName:@"onVideoLoad" body:@{@"duration": [NSNumber numberWithFloat:duration], @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)], @"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse], @@ -247,7 +247,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" [self attachListeners]; [self applyModifiers]; } else if(_playerItem.status == AVPlayerItemStatusFailed) { - [_eventDispatcher sendInputEventWithName:RNVideoEventLoadingError + [_eventDispatcher sendInputEventWithName:@"onVideoError" body:@{@"error": @{ @"code": [NSNumber numberWithInteger: _playerItem.error.code], @"domain": _playerItem.error.domain}, @@ -275,7 +275,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" - (void)playerItemDidReachEnd:(NSNotification *)notification { - [_eventDispatcher sendInputEventWithName:RNVideoEventEnd body:@{@"target": self.reactTag}]; + [_eventDispatcher sendInputEventWithName:@"onVideoEnd" body:@{@"target": self.reactTag}]; if (_repeat) { AVPlayerItem *item = [notification object]; @@ -320,7 +320,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" if (CMTimeCompare(current, cmSeekTime) != 0) { [_player seekToTime:cmSeekTime toleranceBefore:tolerance toleranceAfter:tolerance completionHandler:^(BOOL finished) { - [_eventDispatcher sendInputEventWithName:RNVideoEventSeek + [_eventDispatcher sendInputEventWithName:@"onVideoSeek" body:@{@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(item.currentTime)], @"seekTime": [NSNumber numberWithFloat:seekTime], @"target": self.reactTag}]; diff --git a/RCTVideoManager.m b/RCTVideoManager.m index 9346f6f2..3f931999 100644 --- a/RCTVideoManager.m +++ b/RCTVideoManager.m @@ -16,28 +16,16 @@ RCT_EXPORT_MODULE(); /* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */ -- (NSDictionary *)customDirectEventTypes +- (NSArray *)customDirectEventTypes { - return @{ - RNVideoEventLoading: @{ - @"registrationName": @"onVideoLoadStart" - }, - RNVideoEventLoaded: @{ - @"registrationName": @"onVideoLoad" - }, - RNVideoEventLoadingError: @{ - @"registrationName": @"onVideoError" - }, - RNVideoEventProgress: @{ - @"registrationName": @"onVideoProgress" - }, - RNVideoEventSeek: @{ - @"registrationName": @"onVideoSeek" - }, - RNVideoEventEnd: @{ - @"registrationName": @"onVideoEnd" - } - }; + return @[ + @"onVideoLoadStart", + @"onVideoLoad", + @"onVideoError", + @"onVideoProgress", + @"onVideoSeek", + @"onVideoEnd" + ]; } - (dispatch_queue_t)methodQueue From b43d11f17b22dc77f9e1939fac47e382851e3b23 Mon Sep 17 00:00:00 2001 From: React Native Playground Date: Sun, 23 Aug 2015 02:30:18 +0200 Subject: [PATCH 2/2] remove unused constants --- RCTVideo.h | 7 ------- RCTVideo.m | 7 ------- 2 files changed, 14 deletions(-) diff --git a/RCTVideo.h b/RCTVideo.h index 7341332c..1fc82e43 100644 --- a/RCTVideo.h +++ b/RCTVideo.h @@ -1,12 +1,5 @@ #import "RCTView.h" -extern NSString *const RNVideoEventLoaded; -extern NSString *const RNVideoEventLoading; -extern NSString *const RNVideoEventProgress; -extern NSString *const RNVideoEventSeek; -extern NSString *const RNVideoEventLoadingError; -extern NSString *const RNVideoEventEnd; - @class RCTEventDispatcher; @interface RCTVideo : UIView diff --git a/RCTVideo.m b/RCTVideo.m index f0b74e25..37e09e8b 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -5,13 +5,6 @@ #import "UIView+React.h" #import -NSString *const RNVideoEventLoaded = @"videoLoaded"; -NSString *const RNVideoEventLoading = @"videoLoading"; -NSString *const RNVideoEventProgress = @"videoProgress"; -NSString *const RNVideoEventSeek = @"videoSeek"; -NSString *const RNVideoEventLoadingError = @"videoLoadError"; -NSString *const RNVideoEventEnd = @"videoEnd"; - static NSString *const statusKeyPath = @"status"; static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp";