最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - React native video rotation - Stack Overflow

programmeradmin2浏览0评论

React native expo video view is not rotating the video.

I want to rotate a react native video view to 90deg, I am seeing only the video controllers are getting rotated but the video is still in that mode. I am building a video player for the TVs.

I have tried this:

<VideoView
  style={styles.video}
  player={player}
  source={source}
  contentFit="contain"
  allowsFullscreen
  rotation={Number(orientation)}
  onError={(error) => console.error("Video loading error:", error)}
  nativeControls={false}
/>

React native expo video view is not rotating the video.

I want to rotate a react native video view to 90deg, I am seeing only the video controllers are getting rotated but the video is still in that mode. I am building a video player for the TVs.

I have tried this:

<VideoView
  style={styles.video}
  player={player}
  source={source}
  contentFit="contain"
  allowsFullscreen
  rotation={Number(orientation)}
  onError={(error) => console.error("Video loading error:", error)}
  nativeControls={false}
/>
Share Improve this question edited Mar 11 at 23:38 Nguyen Tien Dung 6384 gold badges10 silver badges34 bronze badges asked Mar 9 at 9:37 Shiva Kumar SahooShiva Kumar Sahoo 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You are directly trying to rotate videoView which might not rotate in some cases, instead you could try to rotate the container like this.

<View style={[styles.container, { transform: [{ rotate: orientation ? `${orientation}deg` : '0deg'}] }]}>
   <VideoView
      style={styles.video}
      source={source}
      resizeMode="contain" //or "cover" according to your preference
      shouldPlay
      isLooping
      useNativeControls={false}
      />
   </View>
  );
};

发布评论

评论列表(0)

  1. 暂无评论