TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.15k stars 2.88k forks source link

React native web will not compile with react-native-video #2719

Open hellolgl opened 2 years ago

hellolgl commented 2 years ago
ERROR in ./node_modules/react-native-video/Video.js 55:7 Module parse failed: Unexpected token (55:7) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders }
seek = (time, tolerance = 100) => { if (isNaN(time)) {throw new Error('Specified time is not a number');}

package.json

"react-native-video": "^5.2.0",

hueniverse commented 2 years ago

We are removing support for DOM.

Leena-Sharma-rsys commented 2 years ago

Can you add support for react-native web instead of having React-native-dom as this library is not maintained now.

haveamission commented 2 years ago

@hueniverse React Native Web is not React Native DOM. React Native Web is much more strongly supported and used, including by large orgs such as Twitter.

haveamission commented 2 years ago

@Leena-Sharma-rsys Expo supports expo-av, which seems to have video support:

https://docs.expo.dev/versions/v46.0.0/sdk/av/

realchrisolin commented 2 years ago

How is "we are removing support for DOM" a valid resolution for this issue?

The 5.2.0 version of this plugin is effectively broken and throws this "Unexpected token (55:7)" error without any clear or intuitive resolution. Please provide a viable workaround or reopen this issue so a fix can be prioritized.

freeboub commented 2 years ago

@realchrisolin i agree, please provide a fix for this issue...

joshlbaker commented 2 years ago

Bump! Should I downgrade or what?

evoactivity commented 2 years ago

At some point in the future I am going to want react-native-web support. I'm willing to work on that myself, but it is 100% a spare time thing so if anyone else needs support and can work on it straight away go ahead. I'll keep an eye on this issue and update if I make any progress.

framerate commented 7 months ago

To anyone seeing this issue, what is the fix in 2024?

Have some platform checks and load a different video player for the web?

joshlbaker commented 7 months ago

To anyone seeing this issue, what is the fix in 2024?

Have some platform checks and load a different video player for the web?

Yep this is what my team had to do. Cleanest way is to create a Video.web.tsx file and add your web-only logic there.

import {createElement} from 'react-native-web';

export default function Video({src, height, width}) {
  const attrs = {
    src,
    height,
    width,
    controls: true,
    autoPlay: false,
    ...
  };

  return createElement('video', attrs);
}
freeboub commented 7 months ago

@joshlbaker if you can open a pull request for that, it wouild be wonderfull !

zoriya commented 4 months ago

I wrote a video.web component that is mostly a 1to1 mapping of rnv props, if there is interest I can upstream it, but it does not contain all features of rnv (no ads or drm support for example). I also need HLS and advanced subtitles support, so I use hls.js and some subtitle renderer in js. I think subtitles renderer don't need to be integrated here as long as a HTMLVideoElement ref is still available, but I think having hls built-in is good.

KrzysztofMoch commented 4 months ago

@zoriya you can contact me when you will have time and we can upstream this!

zoriya commented 3 months ago

I'll probably have the time at the end of the month, early next month. I think I'll stick with a vanilla video player and let users handle hls/special media themselves.

NadiaMit commented 1 month ago

Are there any updates?

KrzysztofMoch commented 1 month ago

There is PR for web support #3958 - I think I will have time to review and merge this soon

arijitsarkar2k14 commented 1 month ago

The PR to support react-native-web is still open. When are you guys planning to merge the PR?