Skip to content

Commit

Permalink
Merge pull request #1057 from genglei01/master
Browse files Browse the repository at this point in the history
Add allowsExternalPlayback Property for ios
  • Loading branch information
cobarx authored Jun 10, 2018
2 parents 7351527 + 36dffa6 commit bd30454
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ var styles = StyleSheet.create({
```

### Configurable props
* [allowsExternalPlayback](#allowsexternalplayback)
* [ignoreSilentSwitch](#ignoresilentswitch)
* [muted](#muted)
* [paused](#paused)
Expand All @@ -235,6 +236,13 @@ var styles = StyleSheet.create({
* [useTextureView](#usetextureview)
* [volume](#volume)

#### allowsExternalPlayback
Indicates whether the player allows switching to external playback mode such as AirPlay or HDMI.
* **true (default)** - allow switching to external playback mode
* **false** - Don't allow switching to external playback mode

Platforms: iOS

#### ignoreSilentSwitch
Controls the iOS silent switch behavior
* **"inherit" (default)** - Use the default AVPlayer behavior
Expand Down
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ Video.propTypes = {
poster: PropTypes.string,
posterResizeMode: Image.propTypes.resizeMode,
repeat: PropTypes.bool,
allowsExternalPlayback: PropTypes.bool,
selectedTextTrack: PropTypes.shape({
type: PropTypes.string.isRequired,
value: PropTypes.oneOfType([
Expand Down
9 changes: 9 additions & 0 deletions ios/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ @implementation RCTVideo
BOOL _muted;
BOOL _paused;
BOOL _repeat;
BOOL _allowsExternalPlayback;
NSDictionary * _selectedTextTrack;
BOOL _playbackStalled;
BOOL _playInBackground;
Expand Down Expand Up @@ -67,6 +68,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
_controls = NO;
_playerBufferEmpty = YES;
_playInBackground = false;
_allowsExternalPlayback = YES;
_playWhenInactive = false;
_ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey

Expand Down Expand Up @@ -523,6 +525,12 @@ - (void)setPlayInBackground:(BOOL)playInBackground
_playInBackground = playInBackground;
}

- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback
{
_allowsExternalPlayback = allowsExternalPlayback;
_player.allowsExternalPlayback = _allowsExternalPlayback;
}

- (void)setPlayWhenInactive:(BOOL)playWhenInactive
{
_playWhenInactive = playWhenInactive;
Expand Down Expand Up @@ -635,6 +643,7 @@ - (void)applyModifiers
[self setRepeat:_repeat];
[self setPaused:_paused];
[self setControls:_controls];
[self setAllowsExternalPlayback:_allowsExternalPlayback];
}

- (void)setRepeat:(BOOL)repeat {
Expand Down
1 change: 1 addition & 0 deletions ios/RCTVideoManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ - (dispatch_queue_t)methodQueue
RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString);
RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL);
RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL);
RCT_EXPORT_VIEW_PROPERTY(selectedTextTrack, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(paused, BOOL);
RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);
Expand Down

0 comments on commit bd30454

Please sign in to comment.