Merge pull request #1723 from blitzcrank/master
Added support for automaticallyWaitsToMinimizeStalling property on iOS
This commit is contained in:
		| @@ -1,5 +1,8 @@ | ||||
| ## Changelog | ||||
|  | ||||
| ### next | ||||
| * Added support for automaticallyWaitsToMinimizeStalling property (iOS) [#1723](https://github.com/react-native-community/react-native-video/pull/1723) | ||||
|  | ||||
| ### Version 5.0.2 | ||||
| * Fix crash when RCTVideo's superclass doesn't observe the keyPath 'frame' (iOS) [#1720](https://github.com/react-native-community/react-native-video/pull/1720) | ||||
|  | ||||
|   | ||||
| @@ -292,6 +292,7 @@ var styles = StyleSheet.create({ | ||||
| ### Configurable props | ||||
| * [allowsExternalPlayback](#allowsexternalplayback) | ||||
| * [audioOnly](#audioonly) | ||||
| * [automaticallyWaitsToMinimizeStalling](#automaticallyWaitsToMinimizeStalling) | ||||
| * [bufferConfig](#bufferconfig) | ||||
| * [controls](#controls) | ||||
| * [filter](#filter) | ||||
| @@ -370,6 +371,13 @@ For this to work, the poster prop must be set. | ||||
|  | ||||
| Platforms: all | ||||
|  | ||||
| #### automaticallyWaitsToMinimizeStalling | ||||
| A Boolean value that indicates whether the player should automatically delay playback in order to minimize stalling. For clients linked against iOS 10.0 and later | ||||
| * **false** - Immediately starts playback | ||||
| * **true (default)** - Delays playback in order to minimize stalling | ||||
|  | ||||
| Platforms: iOS | ||||
|  | ||||
| #### bufferConfig | ||||
| Adjust the buffer settings. This prop takes an object with one or more of the properties listed below. | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								Video.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Video.js
									
									
									
									
									
								
							| @@ -382,6 +382,7 @@ Video.propTypes = { | ||||
|   poster: PropTypes.string, | ||||
|   posterResizeMode: Image.propTypes.resizeMode, | ||||
|   repeat: PropTypes.bool, | ||||
|   automaticallyWaitsToMinimizeStalling: PropTypes.bool, | ||||
|   allowsExternalPlayback: PropTypes.bool, | ||||
|   selectedAudioTrack: PropTypes.shape({ | ||||
|     type: PropTypes.string.isRequired, | ||||
|   | ||||
| @@ -54,6 +54,7 @@ static int const RCTVideoUnset = -1; | ||||
|   float _rate; | ||||
|   float _maxBitRate; | ||||
|  | ||||
|   BOOL _automaticallyWaitsToMinimizeStalling; | ||||
|   BOOL _muted; | ||||
|   BOOL _paused; | ||||
|   BOOL _repeat; | ||||
| @@ -87,7 +88,7 @@ static int const RCTVideoUnset = -1; | ||||
| { | ||||
|   if ((self = [super init])) { | ||||
|     _eventDispatcher = eventDispatcher; | ||||
|      | ||||
| 	  _automaticallyWaitsToMinimizeStalling = YES; | ||||
|     _playbackRateObserverRegistered = NO; | ||||
|     _isExternalPlaybackActiveObserverRegistered = NO; | ||||
|     _playbackStalled = NO; | ||||
| @@ -376,6 +377,9 @@ static int const RCTVideoUnset = -1; | ||||
|       _isExternalPlaybackActiveObserverRegistered = YES; | ||||
|          | ||||
|       [self addPlayerTimeObserver]; | ||||
|       if (@available(iOS 10.0, *)) { | ||||
|         [self setAutomaticallyWaitsToMinimizeStalling:_automaticallyWaitsToMinimizeStalling]; | ||||
|       } | ||||
|  | ||||
|       //Perform on next run loop, otherwise onVideoLoadStart is nil | ||||
|       if (self.onVideoLoadStart) { | ||||
| @@ -864,7 +868,13 @@ static int const RCTVideoUnset = -1; | ||||
|     } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { | ||||
|       [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; | ||||
|     } | ||||
|     [_player play]; | ||||
|      | ||||
| 	if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) { | ||||
| 		[_player playImmediatelyAtRate:1.0]; | ||||
| 	} else { | ||||
| 		[_player play]; | ||||
| 		[_player setRate:_rate]; | ||||
| 	} | ||||
|     [_player setRate:_rate]; | ||||
|   } | ||||
|    | ||||
| @@ -951,6 +961,12 @@ static int const RCTVideoUnset = -1; | ||||
|   _playerItem.preferredPeakBitRate = maxBitRate; | ||||
| } | ||||
|  | ||||
| - (void)setAutomaticallyWaitsToMinimizeStalling:(BOOL)waits | ||||
| { | ||||
| 	_automaticallyWaitsToMinimizeStalling = waits; | ||||
| 	_player.automaticallyWaitsToMinimizeStalling = waits; | ||||
| } | ||||
|  | ||||
|  | ||||
| - (void)applyModifiers | ||||
| { | ||||
|   | ||||
| @@ -22,6 +22,7 @@ RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary); | ||||
| RCT_EXPORT_VIEW_PROPERTY(maxBitRate, float); | ||||
| RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString); | ||||
| RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL); | ||||
| RCT_EXPORT_VIEW_PROPERTY(automaticallyWaitsToMinimizeStalling, BOOL); | ||||
| RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL); | ||||
| RCT_EXPORT_VIEW_PROPERTY(textTracks, NSArray); | ||||
| RCT_EXPORT_VIEW_PROPERTY(selectedTextTrack, NSDictionary); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user