Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src is not set when using file #1508

Closed
amacpherson-upsiide opened this issue Sep 20, 2022 · 18 comments
Closed

src is not set when using file #1508

amacpherson-upsiide opened this issue Sep 20, 2022 · 18 comments

Comments

@amacpherson-upsiide
Copy link

amacpherson-upsiide commented Sep 20, 2022

Current Behavior

When setting URL = a mp4 the video SRC is never set, thus the player never loads. Occasionally when hot reloading kicks in the player will work.

Expected Behavior

setting url="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4" should work

also tried, url={[{src: 'https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4'}]}

Steps to Reproduce

  • create react app
  • import import ReactPlayer from 'react-player/file'; OR import ReactPlayer from 'react-player';
  • add player
    <ReactPlayer url="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4" controls />
    Screen Shot 2022-09-20 at 3 16 27 PM

Other Information

@amacpherson-upsiide
Copy link
Author

I can also see an error returned by the onError call back with the following...
MEDIA_ELEMENT_ERROR: Empty src attribute

@amacpherson-upsiide
Copy link
Author

Downgraded CRA to react 17 and things seem to be working so chalking this up to an issue with React 18 specifically.

@cookpete
Copy link
Owner

Could this be a weird side effect of #1360? Not sure what’s going on here.

@kayden-kim
Copy link

I have same issue too. I think that 'src' should be set again when component is re-mounted.

https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state

With Strict Mode starting in React 18, whenever a component mounts in development, React will simulate immediately unmounting and remounting the component

@usamamashkoor
Copy link

I am facing the same issue with React.js 18 and Next.js, did any one find a solution for this?

@rklf
Copy link

rklf commented Sep 23, 2022

I was facing also this issue (React 18.2.0 - react-player 2.11.0)

Comment (or removing) <React.StrictMode> tag is fixing that in development environment (NODE_ENV), it is working in production environment (when app is built) though since <React.StrictMode> is ignored in production

@nickchauhan
Copy link

Downgrading react-player to v2.10.1 or removing <React.StrictMode> fixes the issue. I believe the problem is PR #1360.

@kevin-guertin
Copy link

I have the same issue in React 18. Downgrading to v2.10.1 does NOT fix the issue. Everything is fine after removing <React.StrictMode> as mentioned previously in both v2.10.1 and v2.11.0. However, that is not an acceptable fix.

In my function component, I do not render the video player at all if the URL string happens to be empty/null/undefined.

Here is part of the error that is generated from the onError callback. This same error happens in v2.10.1 and in v2.11.0 in React 18. You can see that my local video file path appears in the currentSrc property so it looks like the component is receiving the proper URL.

image

@furkan-cat
Copy link

furkan-cat commented Oct 8, 2022

Downgrading react-player to v2.10.1 or removing <React.StrictMode> fixes the issue. I believe the problem is PR #1360.

Yep when i remove the strict mode, all works fine. Is there any solution for this issue?

@Hydrock
Copy link

Hydrock commented Nov 26, 2022

Downgrading react-player to v2.10.1 or removing <React.StrictMode> fixes the issue. I believe the problem is PR #1360.

I can't downgrade react because i use NextJS last version, but downgrading react-player to v2.10.1 is helped me. Thank you gues a lot.

@cookpete
Copy link
Owner

cookpete commented Feb 3, 2023

Hopefully fixed by #1538

@cookpete cookpete closed this as completed Feb 3, 2023
@phcorp
Copy link

phcorp commented Mar 1, 2023

was not fixed by #1538 for me (I'm using v2.11.2)

the problem appears for urls provided as an array of objects with type and src properties
the problem does not appear when the URL is provided as a string

I have tested on audio files so far, I guess the problem is the same on video files

@jamesryan-dev
Copy link

jamesryan-dev commented Mar 20, 2023

I am also experiencing this issue:

Screenshot 2023-03-20 at 10 10 48

  return (
    <ReactPlayer
      //   url="https://www.youtube.com/watch?v=y9j-BL5ocW8"
      url={[
        { src: "/retail-video.webm", type: "video/webm" },
        { src: "/retail-video2.mp4", type: "video/mp4" },
      ]}
      loop={true}
      playing={true}
      controls={false}
      muted={true}
      width="100%"
      height="100%"
      config={{
        youtube: {
          playerVars: {
            start: "10",
          },
        },
      }}
    />
  );
 "react-player": "^2.12.0",

@davshoward
Copy link

Also experiencing this. Single string works fine, array of either strings or objects fails.

@phcorp
Copy link

phcorp commented Apr 14, 2023

#1612 fixes this

@aayodejii
Copy link

The issue is yet to be resolved, I'm using 2.12.0
image

@otwm
Copy link

otwm commented Jun 30, 2023

스크린샷 2023-06-30 오후 8 49 24 me too, The issue is yet to be resolved, I'm using 2.12.0

@mohamedanushkar
Copy link

Me too, cant play multiple urls for safari and chrome. anyone know s a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests