From 9c5ecec5d7f30e4febeed331f3b3a309587ac82b Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 21 Apr 2020 21:28:23 +0100 Subject: [PATCH] Revert "Add prop to force fullscreen preview for videos. (#20436)" This reverts commit e19b804e69e1f1ebc9f1879ee249ff6f9304db9f. --- .../components/video-player/index.native.js | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/block-editor/src/components/video-player/index.native.js b/packages/block-editor/src/components/video-player/index.native.js index 2a73172f32e09c..a409c1d4ad99fc 100644 --- a/packages/block-editor/src/components/video-player/index.native.js +++ b/packages/block-editor/src/components/video-player/index.native.js @@ -25,6 +25,7 @@ class Video extends Component { super( ...arguments ); this.isIOS = Platform.OS === 'ios'; this.state = { + isFullScreen: false, videoContainerHeight: 0, }; this.onPressPlay = this.onPressPlay.bind( this ); @@ -83,12 +84,8 @@ class Video extends Component { } render() { - const { - isSelected, - style, - forceFullscreen = ! this.isIOS, - } = this.props; - const { videoContainerHeight } = this.state; + const { isSelected, style } = this.props; + const { isFullScreen, videoContainerHeight } = this.state; const showPlayButton = videoContainerHeight > 0; return ( @@ -98,12 +95,21 @@ class Video extends Component { ref={ ( ref ) => { this.player = ref; } } - pointerEvents={ isSelected ? undefined : 'none' } - controls={ ! forceFullscreen } + // Using built-in player controls is messing up the layout on iOS. + // So we are setting controls=false and adding a play button that + // will trigger presentFullscreenPlayer() + controls={ false } ignoreSilentSwitch={ 'ignore' } + paused={ ! isFullScreen } onLayout={ this.onVideoLayout } + onFullscreenPlayerWillPresent={ () => { + this.setState( { isFullScreen: true } ); + } } + onFullscreenPlayerDidDismiss={ () => { + this.setState( { isFullScreen: false } ); + } } /> - { showPlayButton && forceFullscreen && ( + { showPlayButton && ( // If we add the play icon as a subview to VideoPlayer then react-native-video decides to show control buttons // even if we set controls={ false }, so we are adding our play button as a sibling overlay view.