I have used react native video player in my app. i wanted to set video on full screen but crop from both side. I have used 'window' height and width
width: Dimensions.get('window').width
height: Dimensions.get('window').height
But its not working on fullscreen mobile like latest device screen.
<View style={customStyles.videoWrapper}>
{
video.uri !== '' ?
<Video
{...props}
style={[
styles.video,
this.getSizeStyles(),
style,
customStyles.video,
]}
ref={p => {
this.player = p;
}}
muted={this.props.muted || this.state.isMuted}
paused={this.props.paused
? this.props.paused || !this.state.isPlaying
: !this.state.isPlaying}
fullscreenOrientation={"all"}
onProgress={this.onProgress}
onEnd={this.onEnd}
onBuffer={this.onBuffer}
onLoad={this.onLoad}
source={video}
fullscreen={this.state.isFullscreen}
resizeMode={resizeMode}
rate={this.props.rate}
/> :
<View style={[this.getSizeStyles(), {backgroundColor: '#000'}]}/>
}
<View
style={[
this.getSizeStyles(),
{marginTop: -this.getSizeStyles().height}
]}
>
<TouchableOpacity
style={styles.overlayButton}
onPress={() => {
this.showControls();
if (pauseOnPress)
this.onPlayPress();
}}
onLongPress={() => {
if (fullScreenOnLongPress && Platform.OS !== 'android')
this.onToggleFullScreen();
}}
/>
{this.state.isBuffering ? this.renderBuffer() :
(this.state.isControlsVisible)
? this.renderControls() : null}
</View>
</View>
here is video style
video: {
backgroundColor: 'black',
},
getStyle stylesheet
getSizeStyles() {
const {videoWidth, videoHeight} = this.props;
const {width} = this.state;
const ratio = videoHeight / videoWidth;
if (this.state.isFullscreen) {
return {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
}
}
return {
height: width * ratio,
width,
};
}
i have create fullScreen function with orientation
onToggleFullScreen() {
console.log("PixelRatio ",PixelRatio.startDetecting)
if (this.props.onFullscreen) {
this.props.onFullscreen(!this.state.isFullscreen);
}
this.state.isFullscreen ? Orientation.lockToPortrait() : Orientation.lockToLandscapeLeft();
if (this.player !== null) {
this.player.presentFullscreenPlayer();
}
if (Platform.OS === 'android') {
this.onAndroidFullScreenToggle();
}
this.setState({
isFullscreen: !this.state.isFullscreen
});
}
Try this might help