首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react-native-video this.player.presentFullscreenPlayer()自动横屏

react-native-video this.player.presentFullscreenPlayer()自动横屏
EN

Stack Overflow用户
提问于 2018-01-15 19:44:29
回答 1查看 1.8K关注 0票数 1

通过使用react-native-video,在iOS中如何调用this.player.presentFullscreenPlayer()并直接旋转到横屏。我曾尝试在调用this.player.presentFullscreenPlayer()时一起使用react-native-orientation to Orientation.lockToLandscape();,但似乎不起作用。在RTCVideo.m中有一个调用setFullscreen的函数,有谁知道如何修改,以便当触发this.player.presentFullscreenPlayer()时,它从风景开始,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2018-01-16 15:27:14

我在react-native-orientation上尝试了一些类似的东西,它对我来说很有效。你可以做这样的事情。

代码语言:javascript
复制
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;

这将很好地与旋转一起工作。但包中有一个小故障,它将默认方向设置为启用所有方向,因此您可能希望更改此设置,否则您的整个应用程序将启用横向。

代码语言:javascript
复制
static UIInterfaceOrientationMask _orientation = UIInterfaceOrientationMaskAllButUpsideDown;
+ (void)setOrientation: (UIInterfaceOrientationMask)orientation {
  _orientation = orientation;
}
+ (UIInterfaceOrientationMask)getOrientation {
  return _orientation;
}

source

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48262334

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档