6

Is there any solutions for playing video in React-Native-Web

React-Native-Web: https://github.com/necolas/react-native-web

React-Native-Video: https://github.com/react-native-community/react-native-video

2 Answers 2

6

I don't know how viable this solution is but since you are targeting web, you could use and abuse the createElementfrom react-native-web to create a video element.

For example you could create a stateless component like this:

import { createElement } from "react-native-web"; const Video = (props) => { const attrs = { src: props.source, poster: props.poster, controls: "controls" } return createElement("video", attrs) } export default Video 

And then use it in your app like this:

<Video source={require("./stock_video.mp4")} poster={'https://www.fillmurray.com/480/300'} /> 

Here's a little demo how it would work.

Sign up to request clarification or add additional context in comments.

2 Comments

How can I use srcObject in react native?
createElement no longer exists and is replaced by unstable_createElement. necolas.github.io/react-native-web/docs/unstable-apis
0

You can go with the expo av to show the video in react native web. the expo video directly supported for the web.

import { Video } from 'expo-av'; <Video ref={/* ref for the player */} style={/* style for the video player */} source={{ uri: '', // URI to render the video }} /> 

Reference: https://docs.expo.dev/versions/latest/sdk/video-av/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.