Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

How to switch to full screen(rotate to landscape on click of full-screen button on YouTube player gui) in React Native youtube iframe?

$
0
0

I want to switch the player to landscape mode on click of the full-screen button on the player gui. I am using expo so i used expo orientation, I am able to switch to the landscape mode by calling a function on onfullscreenchange prop, but after exiting fullscreen mode the app is locked in landscape mode. How do i fix it?

my code:

VideoPlayer.js

    import React from "react";    import { View, Dimensions } from "react-native";    import YoutubePlayer from "react-native-youtube-iframe";    import * as ScreenOrientation from "expo-screen-orientation";    const VideoPlayer = () => {      function setOrientation() {        if (Dimensions.get("window").height > Dimensions.get("window").width) {          //Device is in portrait mode, rotate to landscape mode.          ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE);        } else {          //Device is in landscape mode, rotate to portrait mode.          ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT);        }      }      return (<View          style={{            width: "100%",            height: 220,          }}><YoutubePlayer            height={300}            play={false}            videoId={"Dv7gLpW91DM"}            onFullScreenChange={setOrientation}          /></View>      );    };    export default VideoPlayer;

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>