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

Youtube: Uncaught TypeError: Cannot redefine property: playbackRate #1108

Closed
Scrity1976 opened this issue Jul 20, 2018 · 5 comments
Closed

Comments

@Scrity1976
Copy link

Scrity1976 commented Jul 20, 2018

Expected behaviour

No errors playing Youtube videos with Plyr

Actual behaviour

Sometimes Youtube video plays without sound and throws error in console:

Uncaught TypeError: Cannot redefine property: playbackRate
    at Function.defineProperty (<anonymous>)
    at onReady (youtube.js:288)
    at M.h.G (www-widgetapi.js:48)
    at Y.h.o (www-widgetapi.js:92)
    at Y.h.H (www-widgetapi.js:105)
    at Wa.g (www-widgetapi.js:81)
    at Oa.f (www-widgetapi.js:70)
onReady @ youtube.js:288
h.G @ www-widgetapi.js:48
h.o @ www-widgetapi.js:92
h.H @ www-widgetapi.js:105
Wa.g @ www-widgetapi.js:81
Oa.f @ www-widgetapi.js:70

Environment

  • Browser: Chrome 67.0.3396.99 64 bit.
  • Version: v.3.3.22
  • Operating System: Windows 10 64 bit.

Steps to reproduce

It may be difficult to reproduce this error.

  • Embed Youtube video to Plyr.
  • Reload page few times,

Edit: Also noticed, that not all Youtube videos have thumbnail images, but Plyr always tries to load them, and it causes Cannot redefine property: playbackRate error and GET https://img.youtube.com/vi/2tOMS4OdO4c/maxresdefault.jpg 404 () Failed to load resource: the server responded with status of 404 (Not Found)

Edit 2: Also noticed this error together with Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://...'). h.B @ www-widgetapi.js:99

@friday
Copy link
Collaborator

friday commented Jul 20, 2018

I'm guessing onReady is being called twice for some reason. Pretty sure this is in no way connected to posters.

@friday
Copy link
Collaborator

friday commented Jul 20, 2018

If someone getting this issue could help out debugging, that would be appreciated. I would try to find out why / if onReady is being called twice. There may be some issue with the setup method, or this is an actual YouTube issue.

@Scrity1976
Copy link
Author

Fixed it by adding check for onReady function, example:

var isVideoReady = false;
onReady: function onReady(event) {
	if(!isVideoReady){
		isVideoReady = true;
		// onReady code here...
	}
}

@friday
Copy link
Collaborator

friday commented Jul 28, 2018

I wasn't able to replicate it, but have submitted a PR anyway.

About your footnotes

Also noticed, that not all Youtube videos have thumbnail images, but Plyr always tries to load them, and it causes Cannot redefine property: playbackRate error and GET https://img.youtube.com/vi/2tOMS4OdO4c/maxresdefault.jpg 404 () Failed to load resource: the server responded with status of 404 (Not Found)

All Youtube videos have thumbnail images, but they don't all have the largest resolution. The only way to find out which resolutions are supported is trying. Trying means you get 404's in the console. These aren't Javascript errors. It's just the console trying to be helpful.

See #963

Also noticed this error together with `Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://...').
h.B @ www-widgetapi.js:99

That's in their code, and can't be avoided. You'd get that if you used YouTube embeds without Plyr as well.

@friday
Copy link
Collaborator

friday commented Jul 30, 2018

@Scrity1976: This should now by in Plyr 3.3.23, but since you're having the issue and I never did you may want to verify this.

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

No branches or pull requests

2 participants