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

Twitch videos don't work "Cannot read property 'Player' of undefined" #921

Closed
lfzawacki opened this issue Jun 8, 2020 · 1 comment
Closed

Comments

@lfzawacki
Copy link

Current Behavior

Using version 2.2.0. Videos from Twitch won't play, the following error is printed on the web console:

Uncaught (in promise) TypeError: Cannot read property 'Player' of undefined

The Twitch api file (https://player.twitch.tv/js/embed/v1.js) seems to have loaded correctly.

Expected Behavior

Twitch videos should play normally

Steps to Reproduce

  1. Trying to load any Twitch video url will yield this error.

I've got this application which is integrating with react-player 2.2.0

  1. Go to https://paulo.dev.mconf.com/demo/demoHTML5.jsp?username=lfz&isModerator=true&action=create
  2. Click the '+' button on the left and 'Share an External Video'
  3. Paste a Twitch video (or livestream) link and click 'Share'
  4. The video

Environment

@cookpete
Copy link
Owner

cookpete commented Jun 9, 2020

You have exports set in your global scope, which is confusing the Twitch API and setting exports.Twitch rather than window.Twitch

Normally I would say this isn't ReactPlayer's responsibility to fix, but this is a common problem (#846 #762 #690) and should be quite easy to fix if we just look inside exports as well as window in the getSDK logic.

Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
Players like Vimeo and Twitch have code that will attach the API global on
to `exports` or `module.exports` if it exists, rather than `window`.
This just helps getSDK to look for globals that may have been added there

Fixes cookpete/react-player#921
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
Players like Vimeo and Twitch have code that will attach the API global on
to `exports` or `module.exports` if it exists, rather than `window`.
This just helps getSDK to look for globals that may have been added there

Fixes cookpete/react-player#921
philip-luther added a commit to philip-luther/react-player that referenced this issue Nov 22, 2024
Players like Vimeo and Twitch have code that will attach the API global on
to `exports` or `module.exports` if it exists, rather than `window`.
This just helps getSDK to look for globals that may have been added there

Fixes cookpete/react-player#921
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

2 participants