英文:
How to change orientation of video player on a mobile device using react native expo
问题
我想能够在React Native中使用Expo更改我的视频播放器的方向。但我不知道该如何操作。
到目前为止,我已经完成了以下工作:
import { Video } from "expo-av";
import React, { useState, useRef } from "react";
import { Button, StyleSheet, View } from "react-native";
export default function App() {
const video = React.useRef(null);
const [status, setStatus] = React.useState({});
return (
<View style={styles.container}>
<Video
ref={video}
style={styles.video}
source={{
uri: "http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4",
}}
useNativeControls
resizeMode="contain"
isLooping
onPlaybackStatusUpdate={setStatus}
/>
</View>
);
}
有人可以告诉我接下来该怎么做吗?
英文:
I want to be able to change the orientation of my video player in react native using expo. But I'm not able to find out how.
This is what I've done so far:
import { Video } from "expo-av";
import React, { useState, useRef } from "react";
import { Button, StyleSheet, View } from "react-native";
export default function App() {
const video = React.useRef(null);
const [status, setStatus] = React.useState({});
return (
<View style={styles.container}>
<Video
ref={video}
style={styles.video}
source={{
uri: "http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4",
}}
useNativeControls
resizeMode="contain"
isLooping
onPlaybackStatusUpdate={setStatus}
/>
</View>
);
}
Could anyone help me out on how to proceed?
答案1
得分: 1
你可以使用由Expo提供的ScreenOrientation API,然后有条件地渲染你的组件。
英文:
You can use the ScreenOrientation API provided by Expo and then conditionally render your component.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论