davidohayon669 / react-native-youtube

A <YouTube/> component for React Native.
MIT License
1.16k stars 472 forks source link

locking orientation after closing YouTubeStandaloneAndroid player #324

Open staroflead opened 5 years ago

staroflead commented 5 years ago

My app is portrait locked and I implemented YouTubeStandaloneAndroid for my button. The Library works fine with lightboxMode. I can change device's orientation to landscape for full screen player. However it's unlocked my app's orientation lock on componentDidMount. I have tried to lock orientation again when player exited, but it's not work.

YouTubeStandaloneAndroid.playVideo({ apiKey: 'YOUR_API_KEY', // Your YouTube Developer API Key videoId: '2MpUj-Aua48', // YouTube video ID autoplay: true, // Autoplay the video lightboxMode: true, }) .then(() => {console.log('Standalone Player Exited');}) .catch(errorMessage => console.error(errorMessage)) .finally(() => { this.setState({ isPlayingVideo: false }); Orientation.lockToPortrait(); });

"react-native": "0.51.0" "react-native-youtube": "^1.1.0" "react-native-orientation": "^3.1.0",

Edit: I tried to disable lightboxMode, tried to play a video without tilting device (keep in portrait mode), then close the video. Then app rotated twice, first to landscape, then back to portrait. I also tried not to callOrientation.lockToPotrait() after player exited. App still rotated twice by itself, then it wouldn't rotate anymore even if i switch device's orientation by hand.

kofsiwon commented 3 years ago

YouTubeStandaloneAndroid present portrait video as with landscape. How can it play vertical fullscreen?? iOS works well

kofsiwon commented 3 years ago

I got portrait fullscreen with this solution - https://medium.com/@mridx/youtubestandaloneandroid-play-youtube-videos-in-portrait-mode-in-android-react-native-hack-edd0fdce6088 But I can't go back to portrait after toggling landscape

cyb3rsalih commented 3 years ago

@kofsiwon thanks for the solution. It works!