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:
@@ -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];
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user