Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowsExternalPlayback Property for ios #1057

Merged
merged 6 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var styles = StyleSheet.create({
```

### Configurable props
* [allowsExternalPlayback](#allowsexternalplayback)
* [ignoreSilentSwitch](#ignoresilentswitch)
* [muted](#muted)
* [paused](#paused)
Expand All @@ -233,6 +234,13 @@ var styles = StyleSheet.create({
* [selectedTextTrack](#selectedtexttrack)
* [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