React Native View Shot not capturing video of live stream on ios - react-native

I am using React Native View Shot and I need our product to be able to capture live streaming from a m3u8 uri from React Native video package.
Currently on android it is capturing the screen fine, but on IOS there seems to be an issue of View Shot capturing just a blank video. How it looks on IOS
The livestream is the one playing below and the screenshot is the one taken of the video.
Are they just not compatible, or how would I resolve the issue of capturing a screenshot of a live stream on ios?
<TouchableOpacity onPress={()=>saveCapturedImage()} style={capturedShot ? styles.capturedShotStyle : styles.beforeShotStyle}>
{capturedShot ? <Text/> : <Text>Click to capture shot</Text> }
</TouchableOpacity>
<Image style={capturedShot ? styles.captureContainerPost : styles.captureContainerPre} source={capturedShot ? {uri: capturedShot } : null} />
{/* Viewshot component from React Native Viewshot */}
<ViewShot ref={viewShotRef} options={{ format: "jpg", quality: 0.9 }}>
{/* Video component from React Native Video, resizeMode cover to get full height on the component. Add pause controls for default, and controls can be toggled true/false */}
{videoUri && <Video
source={{
uri: videoUri,
}}
style={{
width: "100%",
height: "100%",
}}
resizeMode="cover"
controls={true}
paused = {false}
/>}
</ViewShot>

If anyone else wants an answer for this problem in future, I wrapped View shot capturing screen over a react native webview component playing a video on ios. It took a photo of a paused Youtube video playing. But even though View Shot captured a WebView of a video embedded, the content of the video was empty.
Not sure if this is because of RN View Shot, have emailed the founder of the package. Or does Ios block video content playing?
<View collapsable={false} style=Template:Height: "80%">
<WebView
originWhitelist={["*"]}
source={{
html:
'<iframe playsinline controls autoplay src="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8" ></iframe>',
}}
useWebKit={true}
originWhitelist={["*"]}
allowsInlineMediaPlayback={true}
style={{
height: 600,
width: 400,
}}
/>
</View>
</ViewShot>
But if anyone finds a better alternative solution let me know.

Related

React Native WebView - Vimeo url not loading images

I am loading a Vimeo video using WebView in ReactNative. However, the images do not load (badge and pre-play image). I am using react-native#0.70.5 and react-native-webview#11.23.1, below is the code for my WebView, and screenshots of the video in the emulator vs. directly accessed over the browser url bar.
<WebView
allowsFullscreenVideo={true}
source={{ uri: "https://player.vimeo.com/video/65107797" }}
javaScriptEnabled={true}
scrollEnabled={false}
originWhitelist={["*"]}
style={{ height: 300 }}
/>
Screenshot of video in iOS emulator:
Screenshot of video in the browser:

How to play YouTube videos in React native player?

I want to play some YouTube videos in my react native app using a native player as we don't want to show youtube branding in the player. Is there any possible way to do this?
If not, what's the best way to play youtube videos in react native app without showing youtube branding?
You can do this using react-native-webview.
<WebView
javaScriptEnabled={true}
domStorageEnabled={true}
scrollEnabled={false}
source={{
uri: `${"YOUR YOUTUBE URL"}?controls=0&showinfo=0&wmode=transparent&rel=0&mode=opaque`,
}}
style={{
height: 200,
width: Dimensions.get('window').width - 80,
}}
onError={(err) => {
console.log(err, 'this is errr');
}}
/>

How to customised useNativeControls in expo-av Video

I want to three icons, two for video playing speed control and another one for video resolution change. Is there any way to add this kind of buttons ??
Here is my player:
<Video
key={videoId}
ref={video}
style={styles.videoPlayer}
source={{
uri: videofiles?.link,
}}
rate={1.0}
posterSource={{ uri: thumbnail }}
usePoster={!isActivity}
useNativeControls
resizeMode={Video.RESIZE_MODE_CONTAIN}
isLooping
onPlaybackStatusUpdate={status => {
statusChangeEvent(status);
}}
onFullscreenUpdate={onFullscreenUpdate}
/>
You can not modify your native controller. But you can use a hacky solution by using Pressable. You have to wrap your video component with Pressable. And after that, you can show your customize modal.
Here is an Example:
<Pressable>
<>
<Video
...
...
/>
//your customize modal
...
...
</>
</Pressable>

React Native WebView does not scroll horizontally on android

Here is my code:
<View style={{ height: this.state.height, ...props.style }}>
<WebView
ref="child"
{...this.props}
scalesPageToFit={false}
scrollEnabled={true}
javaScriptEnabled={true}
domStorageEnabled={true}
startInLoadingState={true}
onMessage={ this.handleMessage.bind(this) }
source={{ html }}
/>
</View>
This works fine on iOS build (Scrolls horizontally) but does not work on Android.
react native WebView has been deprecated you should now use
https://github.com/react-native-community/react-native-webview
First answer is right, you should use react-native-webview now.
And, your problem may be related with your View wrapper I think.

React native youtube - component not visible

I cannot see the player, when mounting to my page:
return (
<YouTube
apiKey="xxx"
videoId={youtubeVideo} // The YouTube video ID
play={false} // control playback of video with true/false
fullscreen={false} // control whether the video should play in fullscreen or inline
loop={false} // control whether the video should loop when ended
onReady={e => console.log('ready')}
onChangeState={e => console.log('onchange')}
onChangeQuality={e => console.log('change quality')}
onError={e => console.log(e.error)}
style={{ alignSelf: "stretch", height: 300 }}
/>
);
I get console logs for the onReady callback but no video. How can I display my video?
Are there any better alternatives? Having looked into these two packages, react-native-youtube and react-native-vimeo. Both haven't been maintained for a while and have various issues.
What is the best way to embed video from youtube that fits guidelines for both Play and App Stores? With lots of video based apps on the Play stores, how does everyone else do it?
Is your YouTube component wrapped inside a parent view with flex ? I'm using the same package in my app and it seems to be working fine and this is pretty much how I've got it set up.
// Parent view (page container)
<View style={{ flex : 1 }}>
...
<Youtube
apiKey={API_KEY}
videoId={videoID}
style={{ marginTop : 15, height : 250, alignSelf : 'stretch' }} />
...
</View>