Support preventsDisplaySleepDuringVideoPlayback (#2019)

* Add flag on iOS

* Add flag in Android

* Add documentation

* Add changelog entry

* Also set setKeepScreenOn

* Fix prop not being set

* add preventsDisplaySleepDuringVideoPlayback to exoplayer

* Update android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* Update android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

Co-authored-by: Jens Andersson <jens@fritan.com>

Co-authored-by: Anton Tanderup <antontandrup@gmail.com>
Co-authored-by: Jens Andersson <jens@fritan.com>
This commit is contained in:
Anders Lemke
2020-06-16 14:31:23 +02:00
committed by GitHub
parent 9c31948dbf
commit 8962720f56
8 changed files with 63 additions and 5 deletions

View File

@@ -64,6 +64,7 @@ static int const RCTVideoUnset = -1;
NSDictionary * _selectedAudioTrack;
BOOL _playbackStalled;
BOOL _playInBackground;
BOOL _preventsDisplaySleepDuringVideoPlayback;
float _preferredForwardBufferDuration;
BOOL _playWhenInactive;
BOOL _pictureInPicture;
@@ -106,6 +107,7 @@ static int const RCTVideoUnset = -1;
_controls = NO;
_playerBufferEmpty = YES;
_playInBackground = false;
_preventsDisplaySleepDuringVideoPlayback = true;
_preferredForwardBufferDuration = 0.0f;
_allowsExternalPlayback = YES;
_playWhenInactive = false;
@@ -815,6 +817,12 @@ static int const RCTVideoUnset = -1;
_playInBackground = playInBackground;
}
- (void)setPreventsDisplaySleepDuringVideoPlayback:(BOOL)preventsDisplaySleepDuringVideoPlayback
{
_preventsDisplaySleepDuringVideoPlayback = preventsDisplaySleepDuringVideoPlayback;
[self applyModifiers];
}
- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback
{
_allowsExternalPlayback = allowsExternalPlayback;
@@ -1021,6 +1029,12 @@ static int const RCTVideoUnset = -1;
[_player setVolume:_volume];
[_player setMuted:NO];
}
if (@available(iOS 12.0, *)) {
self->_player.preventsDisplaySleepDuringVideoPlayback = _preventsDisplaySleepDuringVideoPlayback;
} else {
// Fallback on earlier versions
}
[self setMaxBitRate:_maxBitRate];
[self setSelectedAudioTrack:_selectedAudioTrack];

View File

@@ -32,6 +32,7 @@ RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);
RCT_EXPORT_VIEW_PROPERTY(controls, BOOL);
RCT_EXPORT_VIEW_PROPERTY(volume, float);
RCT_EXPORT_VIEW_PROPERTY(playInBackground, BOOL);
RCT_EXPORT_VIEW_PROPERTY(preventsDisplaySleepDuringVideoPlayback, BOOL);
RCT_EXPORT_VIEW_PROPERTY(preferredForwardBufferDuration, float);
RCT_EXPORT_VIEW_PROPERTY(playWhenInactive, BOOL);
RCT_EXPORT_VIEW_PROPERTY(pictureInPicture, BOOL);