Adds fullscreenOptions to iOS
This commit is contained in:
parent
0580f2710f
commit
443bf88c63
29
README.md
29
README.md
@ -228,6 +228,8 @@ var styles = StyleSheet.create({
|
|||||||
* [allowsExternalPlayback](#allowsexternalplayback)
|
* [allowsExternalPlayback](#allowsexternalplayback)
|
||||||
* [audioOnly](#audioonly)
|
* [audioOnly](#audioonly)
|
||||||
* [bufferConfig](#bufferconfig)
|
* [bufferConfig](#bufferconfig)
|
||||||
|
* [fullscreen (deprecated)](#fullscreen)
|
||||||
|
* [fullscreenOptions](#fullscreenOptions)
|
||||||
* [ignoreSilentSwitch](#ignoresilentswitch)
|
* [ignoreSilentSwitch](#ignoresilentswitch)
|
||||||
* [muted](#muted)
|
* [muted](#muted)
|
||||||
* [paused](#paused)
|
* [paused](#paused)
|
||||||
@ -305,6 +307,33 @@ bufferConfig={{
|
|||||||
|
|
||||||
Platforms: Android ExoPlayer
|
Platforms: Android ExoPlayer
|
||||||
|
|
||||||
|
#### fullscreen (deprecated)
|
||||||
|
|
||||||
|
Controls whether the player enters fullscreen on play. Use fullscreenOptions for extended behaviour.
|
||||||
|
|
||||||
|
Platforms: iOS
|
||||||
|
|
||||||
|
#### fullscreenOptions
|
||||||
|
|
||||||
|
Controls behaviour of the player entering fullscreen, such as forcing landscape playback on portrait devices
|
||||||
|
|
||||||
|
Property | Type | Description
|
||||||
|
--- | --- | ---
|
||||||
|
enabled | boolean | determines whether to enter fullscreen on video play
|
||||||
|
preferredOrientation | landscape, portrait, default | Defaults to the current device orientation; otherwise will force fullscreen video playback into landscape or portrait
|
||||||
|
autorotate | boolean | determines whether the video player will rotate to the preferredOrientation automatically
|
||||||
|
|
||||||
|
Example with default values
|
||||||
|
```
|
||||||
|
fullscreenOptions={{
|
||||||
|
enabled: false,
|
||||||
|
preferredOrientation: 'default'
|
||||||
|
autorotate: true
|
||||||
|
}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Platforms: iOS
|
||||||
|
|
||||||
#### ignoreSilentSwitch
|
#### ignoreSilentSwitch
|
||||||
Controls the iOS silent switch behavior
|
Controls the iOS silent switch behavior
|
||||||
* **"inherit" (default)** - Use the default AVPlayer behavior
|
* **"inherit" (default)** - Use the default AVPlayer behavior
|
||||||
|
@ -119,19 +119,19 @@ static int const RCTVideoUnset = -1;
|
|||||||
|
|
||||||
- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem {
|
- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem {
|
||||||
|
|
||||||
RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init];
|
RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init];
|
||||||
playerLayer.showsPlaybackControls = YES;
|
playerLayer.showsPlaybackControls = YES;
|
||||||
playerLayer.rctDelegate = self;
|
playerLayer.rctDelegate = self;
|
||||||
|
|
||||||
if (_fullscreenOptions) {
|
if (_fullscreenOptions) {
|
||||||
playerLayer.preferredOrientation = [RCTConvert NSString:[_fullscreenOptions objectForKey:@"preferredOrientation"]];
|
playerLayer.preferredOrientation = [RCTConvert NSString:[_fullscreenOptions objectForKey:@"preferredOrientation"]];
|
||||||
playerLayer.autorotate = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"autorotate"]];
|
playerLayer.autorotate = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"autorotate"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
playerLayer.view.frame = self.bounds;
|
playerLayer.view.frame = self.bounds;
|
||||||
playerLayer.player = player;
|
playerLayer.player = player;
|
||||||
playerLayer.view.frame = self.bounds;
|
playerLayer.view.frame = self.bounds;
|
||||||
return playerLayer;
|
return playerLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
@ -222,11 +222,11 @@ static int const RCTVideoUnset = -1;
|
|||||||
|
|
||||||
- (void)audioRouteChanged:(NSNotification *)notification
|
- (void)audioRouteChanged:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
NSNumber *reason = [[notification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey];
|
NSNumber *reason = [[notification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey];
|
||||||
NSNumber *previousRoute = [[notification userInfo] objectForKey:AVAudioSessionRouteChangePreviousRouteKey];
|
NSNumber *previousRoute = [[notification userInfo] objectForKey:AVAudioSessionRouteChangePreviousRouteKey];
|
||||||
if (reason.unsignedIntValue == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) {
|
if (reason.unsignedIntValue == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) {
|
||||||
self.onVideoAudioBecomingNoisy(@{@"target": self.reactTag});
|
self.onVideoAudioBecomingNoisy(@{@"target": self.reactTag});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Progress
|
#pragma mark - Progress
|
||||||
@ -381,7 +381,7 @@ static int const RCTVideoUnset = -1;
|
|||||||
NSString* relativeFilePath = [filepath lastPathComponent];
|
NSString* relativeFilePath = [filepath lastPathComponent];
|
||||||
// the file may be multiple levels below the documents directory
|
// the file may be multiple levels below the documents directory
|
||||||
NSArray* fileComponents = [filepath componentsSeparatedByString:@"/Documents/"];
|
NSArray* fileComponents = [filepath componentsSeparatedByString:@"/Documents/"];
|
||||||
if (fileComponents.count>1) {
|
if (fileComponents.count > 1) {
|
||||||
relativeFilePath = [fileComponents objectAtIndex:1];
|
relativeFilePath = [fileComponents objectAtIndex:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,8 +729,8 @@ static int const RCTVideoUnset = -1;
|
|||||||
|
|
||||||
- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback
|
- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback
|
||||||
{
|
{
|
||||||
_allowsExternalPlayback = allowsExternalPlayback;
|
_allowsExternalPlayback = allowsExternalPlayback;
|
||||||
_player.allowsExternalPlayback = _allowsExternalPlayback;
|
_player.allowsExternalPlayback = _allowsExternalPlayback;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPlayWhenInactive:(BOOL)playWhenInactive
|
- (void)setPlayWhenInactive:(BOOL)playWhenInactive
|
||||||
@ -863,52 +863,52 @@ static int const RCTVideoUnset = -1;
|
|||||||
- (void)setMediaSelectionTrackForCharacteristic:(AVMediaCharacteristic)characteristic
|
- (void)setMediaSelectionTrackForCharacteristic:(AVMediaCharacteristic)characteristic
|
||||||
withCriteria:(NSDictionary *)criteria
|
withCriteria:(NSDictionary *)criteria
|
||||||
{
|
{
|
||||||
NSString *type = criteria[@"type"];
|
NSString *type = criteria[@"type"];
|
||||||
AVMediaSelectionGroup *group = [_player.currentItem.asset
|
AVMediaSelectionGroup *group = [_player.currentItem.asset
|
||||||
mediaSelectionGroupForMediaCharacteristic:characteristic];
|
mediaSelectionGroupForMediaCharacteristic:characteristic];
|
||||||
AVMediaSelectionOption *mediaOption;
|
AVMediaSelectionOption *mediaOption;
|
||||||
|
|
||||||
if ([type isEqualToString:@"disabled"]) {
|
if ([type isEqualToString:@"disabled"]) {
|
||||||
// Do nothing. We want to ensure option is nil
|
// Do nothing. We want to ensure option is nil
|
||||||
} else if ([type isEqualToString:@"language"] || [type isEqualToString:@"title"]) {
|
} else if ([type isEqualToString:@"language"] || [type isEqualToString:@"title"]) {
|
||||||
NSString *value = criteria[@"value"];
|
NSString *value = criteria[@"value"];
|
||||||
for (int i = 0; i < group.options.count; ++i) {
|
for (int i = 0; i < group.options.count; ++i) {
|
||||||
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
||||||
NSString *optionValue;
|
NSString *optionValue;
|
||||||
if ([type isEqualToString:@"language"]) {
|
if ([type isEqualToString:@"language"]) {
|
||||||
optionValue = [currentOption extendedLanguageTag];
|
optionValue = [currentOption extendedLanguageTag];
|
||||||
} else {
|
} else {
|
||||||
optionValue = [[[currentOption commonMetadata]
|
optionValue = [[[currentOption commonMetadata]
|
||||||
valueForKey:@"value"]
|
valueForKey:@"value"]
|
||||||
objectAtIndex:0];
|
objectAtIndex:0];
|
||||||
}
|
}
|
||||||
if ([value isEqualToString:optionValue]) {
|
if ([value isEqualToString:optionValue]) {
|
||||||
mediaOption = currentOption;
|
mediaOption = currentOption;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//} else if ([type isEqualToString:@"default"]) {
|
||||||
|
// option = group.defaultOption; */
|
||||||
|
} else if ([type isEqualToString:@"index"]) {
|
||||||
|
if ([criteria[@"value"] isKindOfClass:[NSNumber class]]) {
|
||||||
|
int index = [criteria[@"value"] intValue];
|
||||||
|
if (group.options.count > index) {
|
||||||
|
mediaOption = [group.options objectAtIndex:index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // default. invalid type or "system"
|
||||||
|
[_player.currentItem selectMediaOptionAutomaticallyInMediaSelectionGroup:group];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//} else if ([type isEqualToString:@"default"]) {
|
|
||||||
// option = group.defaultOption; */
|
|
||||||
} else if ([type isEqualToString:@"index"]) {
|
|
||||||
if ([criteria[@"value"] isKindOfClass:[NSNumber class]]) {
|
|
||||||
int index = [criteria[@"value"] intValue];
|
|
||||||
if (group.options.count > index) {
|
|
||||||
mediaOption = [group.options objectAtIndex:index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // default. invalid type or "system"
|
|
||||||
[_player.currentItem selectMediaOptionAutomaticallyInMediaSelectionGroup:group];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a match isn't found, option will be nil and text tracks will be disabled
|
// If a match isn't found, option will be nil and text tracks will be disabled
|
||||||
[_player.currentItem selectMediaOption:mediaOption inMediaSelectionGroup:group];
|
[_player.currentItem selectMediaOption:mediaOption inMediaSelectionGroup:group];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSelectedAudioTrack:(NSDictionary *)selectedAudioTrack {
|
- (void)setSelectedAudioTrack:(NSDictionary *)selectedAudioTrack {
|
||||||
_selectedAudioTrack = selectedAudioTrack;
|
_selectedAudioTrack = selectedAudioTrack;
|
||||||
[self setMediaSelectionTrackForCharacteristic:AVMediaCharacteristicAudible
|
[self setMediaSelectionTrackForCharacteristic:AVMediaCharacteristicAudible
|
||||||
withCriteria:_selectedAudioTrack];
|
withCriteria:_selectedAudioTrack];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSelectedTextTrack:(NSDictionary *)selectedTextTrack {
|
- (void)setSelectedTextTrack:(NSDictionary *)selectedTextTrack {
|
||||||
@ -1043,25 +1043,25 @@ static int const RCTVideoUnset = -1;
|
|||||||
|
|
||||||
- (NSArray *)getAudioTrackInfo
|
- (NSArray *)getAudioTrackInfo
|
||||||
{
|
{
|
||||||
NSMutableArray *audioTracks = [[NSMutableArray alloc] init];
|
NSMutableArray *audioTracks = [[NSMutableArray alloc] init];
|
||||||
AVMediaSelectionGroup *group = [_player.currentItem.asset
|
AVMediaSelectionGroup *group = [_player.currentItem.asset
|
||||||
mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicAudible];
|
mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicAudible];
|
||||||
for (int i = 0; i < group.options.count; ++i) {
|
for (int i = 0; i < group.options.count; ++i) {
|
||||||
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
||||||
NSString *title = @"";
|
NSString *title = @"";
|
||||||
NSArray *values = [[currentOption commonMetadata] valueForKey:@"value"];
|
NSArray *values = [[currentOption commonMetadata] valueForKey:@"value"];
|
||||||
if (values.count > 0) {
|
if (values.count > 0) {
|
||||||
title = [values objectAtIndex:0];
|
title = [values objectAtIndex:0];
|
||||||
|
}
|
||||||
|
NSString *language = [currentOption extendedLanguageTag] ? [currentOption extendedLanguageTag] : @"";
|
||||||
|
NSDictionary *audioTrack = @{
|
||||||
|
@"index": [NSNumber numberWithInt:i],
|
||||||
|
@"title": title,
|
||||||
|
@"language": language
|
||||||
|
};
|
||||||
|
[audioTracks addObject:audioTrack];
|
||||||
}
|
}
|
||||||
NSString *language = [currentOption extendedLanguageTag] ? [currentOption extendedLanguageTag] : @"";
|
return audioTracks;
|
||||||
NSDictionary *audioTrack = @{
|
|
||||||
@"index": [NSNumber numberWithInt:i],
|
|
||||||
@"title": title,
|
|
||||||
@"language": language
|
|
||||||
};
|
|
||||||
[audioTracks addObject:audioTrack];
|
|
||||||
}
|
|
||||||
return audioTracks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)getTextTrackInfo
|
- (NSArray *)getTextTrackInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user