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

Multiple sources for video not working (url as array of string) #1624

Closed
duranmla opened this issue Apr 27, 2023 · 5 comments
Closed

Multiple sources for video not working (url as array of string) #1624

duranmla opened this issue Apr 27, 2023 · 5 comments

Comments

@duranmla
Copy link

Current Behavior

Valid video doesn't play when passing a url as array, therefore, we can't take advantage of video element API to fallback to different video sources depending on what the browser can play

It seems like src="undefined" is set on the video and perhaps that can be part of the issue? You seem to have a PR for that #1622

Check code sandbox below to check the behavior:

https://codesandbox.io/embed/loving-mcclintock-vefv65?fontsize=14&hidenavigation=1&theme=light

Expected Behavior

I will expect to behave as the video HTML tag such as: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video in which if the first source is wrong or resolve error then goes to the following.

@duranmla duranmla changed the title Multiple sources not working Multiple sources for video not working (url as array of string) Apr 27, 2023
@duranmla
Copy link
Author

Far from ideal but just for the record what I am doing right now is to handle the iteration of different sources until no error found manually:

const handleOnError = useCallback(
  (_error: Error) => {
    if (currentUrlIndex < urls.length - 1) {
      setCurrentUrlIndex(currentUrlIndex + 1);
      return;
    }

    ...
  },
  [/*...*/]
);

<ReactPlayer
    key={urls[currentUrlIndex]} // Important so we are able to 'change' the player on every change of the url to render
    ref={videoRef}
    url={urls[currentUrlIndex]}
    ...
/>

@martavis
Copy link

martavis commented Jul 19, 2023

Since 2.11.1 is the reason for this issue according to this comment, I downgraded to 2.10.0 and it works well.

@luwes
Copy link
Collaborator

luwes commented Oct 10, 2023

fixed in #1612
please comment if not solved on your end.

@luwes luwes closed this as completed Oct 10, 2023
@duranmla
Copy link
Author

duranmla commented Oct 12, 2023

Hey! It seems we have dropped the possibility to throw errors with this last fix, if you check https://codesandbox.io/s/condescending-water-m6qdjr?file=/src/App.js you will see I am using the latest version of the library and there is no console.log of errors despite both video URLs having the "BAD" suffix for them to fail.

@duranmla
Copy link
Author

Trying the above issue at #1692

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

3 participants