通过使用react-native-video,在iOS中如何调用this.player.presentFullscreenPlayer()并直接旋转到横屏。我曾尝试在调用this.player.presentFullscreenPlayer()时一起使用react-native-orientation to Orientation.lockToLandscape();,但似乎不起作用。在RTCVideo.m中有一个调用setFullscreen的函数,有谁知道如何修改,以便当触发this.player.presentFullscreenPlayer()时,它从风景开始,谢谢。
发布于 2018-01-16 15:27:14
我在react-native-orientation上尝试了一些类似的东西,它对我来说很有效。你可以做这样的事情。
import React from "react";
import PropTypes from "prop-types";
import Orientation from "react-native-orientation";
import VideoPlayer from "react-native-video-controls";
const propTypes = {
navigation: PropTypes.object.isRequired,
pageUrl: PropTypes.string.isRequired
};
class VideoDetail extends React.Component {
componentDidMount () {
Orientation.unlockAllOrientations();
}
componentWillUnmount () {
Orientation.lockToPortrait();
}
render () {
return (
<VideoPlayer
disableFullscreen
disableVolume
repeat
goBack={this.goBack}
ignoreSilentSwitch={"ignore"}
source={{
uri: this.props.pageUrl,
type: "mp4"
}}
/>
);
}
}
VideoDetail.propTypes = propTypes;
export default VideoDetail;这将很好地与旋转一起工作。但包中有一个小故障,它将默认方向设置为启用所有方向,因此您可能希望更改此设置,否则您的整个应用程序将启用横向。
static UIInterfaceOrientationMask _orientation = UIInterfaceOrientationMaskAllButUpsideDown;
+ (void)setOrientation: (UIInterfaceOrientationMask)orientation {
_orientation = orientation;
}
+ (UIInterfaceOrientationMask)getOrientation {
return _orientation;
}https://stackoverflow.com/questions/48262334
复制相似问题