I'm currently trying to implement videos from a number of sources into a learning app built with Expo and ReactNative.
I want to include video sources from:
- YouTube
- Vimeo
- Microsoft Stream
- Custom .mp4 link
I have tried to use WebView in the following configuration:
<WebView
ref={videoRef}
onContentProcessDidTerminate={() => videoRef?.current?.reload()}
javaScriptEnabled={true}
sharedCookiesEnabled={true}
scrollEnabled={false}
allowsFullscreenVideo={true}
//allowsInlineMediaPlayback={true}
renderLoading={() => <ActivityIndicator />}
renderError={() => <Text>An error occurred.</Text>}
userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
source={{
uri: src,
}}
mediaPlaybackRequiresUserAction={true}
/>
The experience must be seamless on Android and iOS while allowing for device rotation. When a user starts a video in portrait mode and rotates the device, I need the video to continue playing seamlessly like the YouTube app for instance.
Currently, I am facing the issue, that my solution does not work when rotating the screen. The video stops and the player is closed, the video paused. The orientation then locks back to portrait mode (which is the desired rotation for the app). I have also tried to ScreenOrientation.unlockAsync()
but I am still facing the same issue. Same thing with using <Video />
from expo-av
.
Recapping, some core requirements are:
- The video also needs to be manually started and shall not start on its own.
- Allow for full device-rotational freedom
- Must not stop when rotating the device
- Must work inline and full-screen
- Must allow for multiple sources
- Must work with Android and iOS
How does one go about accomplishing something like that?