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

getVideoData is not a function #709

Closed
2 of 6 tasks
Antonio-Laguna opened this issue Nov 10, 2017 · 19 comments
Closed
2 of 6 tasks

getVideoData is not a function #709

Antonio-Laguna opened this issue Nov 10, 2017 · 19 comments

Comments

@Antonio-Laguna
Copy link
Contributor

Antonio-Laguna commented Nov 10, 2017

I've been recently observing a really high number of errors that are happening on our pages and all are within the lines of the following:

data.message:"Uncaught TypeError: n.getVideoData is not a function" data.lineNumber:2 data.columnNumber:809 data.errorMessage:"n.getVideoData is not a function" data.stack:"TypeError: n.getVideoData is not a function
    at onReady ()
    at K.f.I (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:66:267)
    at W.f.l (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:114:67)
    at W.f.J (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:127:281)
    at S.g (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:143:270)
    at g (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:95:28)" data.userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" data.browser:"Chrome 61.0.3163 / Mac OS X 10.9.5"  

Doing a bit of Google search I found the link you can see below which warns about getVideoData not being a supported function. I can't find it in the docs either. I guess YouTube is releasing a new API version and removing deprecated/unsupported functions yet I can't see it on my machine. I do have several reports though so, it's definitely an issue.

I'd be happy to put time into making a PR with some fix. Let me know if you'd like that.

A quick workaround would be to do a check if the function exists, and it's a function, before actually calling this. This would be beneficial especially if it starts affecting more people.

I've checked and there's no simple way to obtain the title from YouTube, not unless you have an API Key (unless I'm missing something).

Expected behavior

Plyr could try to play safer by checking if getVideoData is defined.

Actual behavior

getVideoData fails some times.

Environment

N/A

Players affected:

  • HTML5 Video
  • HTML5 Audio
  • YouTube
  • Vimeo

Steps to reproduce

Get the video to load. Sometimes that error will pop up.

Relevant links

Bounteous-Inc/youtube-google-analytics#36

@vasanth-qedquest
Copy link

Yep ! I faced similar situation and i am able to see YouTube Iframe API has removed that function from their list. Not able to see in their deprecation list though :(

@Antonio-Laguna
Copy link
Contributor Author

Well, it seemed to be an undocumented function which is why they can do as they please without any warning and anytime to roll.

@arrowthemes
Copy link
Contributor

I can confirm the issue with youtube videos

@sweethoneycode
Copy link

Same thing as of today for me:

s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:121 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://sunflowerschoolhouse.tv'). f.C @ s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:121 plyr.js:1 Uncaught TypeError: n.getVideoData is not a function at onReady (plyr.js:1) at K.f.I (s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:66) at W.f.l (s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:114) at W.f.J (s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:127) at S.g (s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:143) at g (s.ytimg.com/yts/jsbin/www-widgetapi-vflnzpyZ4/www-widgetapi.js:95)

@jayprakash1
Copy link

facing the same issue in production. For now applied a check for that function in my forked repo.

@spencer237
Copy link

the same for me since yesterday :(

@kak2z7702
Copy link

I have the same problem. How can I fix it?

@arrowthemes
Copy link
Contributor

@jayprakash1 after the fix, does it work with youtube videos?

@Antonio-Laguna
Copy link
Contributor Author

That's the same fix I suggested. Check if the function is available before using it, should be pretty safe but I'm unsure if that's what @sampotts would want

@vasanth-qedquest
Copy link

Yes. Checking function against instance.getVideoData !== undefined ? instance.getVideoData().title : ""; in my forked repo, i can able to work around it. Since, we are passing title attribute while loading, this will not have any impact on playing with youtube videos.

@spencer237
Copy link

me too instance.getVideoData !== undefined ? instance.getVideoData().title : "";

@spencer237
Copy link

please how to apply this fix and does it work with YouTube videos?

@jayprakash1
Copy link

@arrowthemes this fix jayprakash1@b336379 worked for me

@sampotts
Copy link
Owner

Sorry fellas, update to v2.0.18 and you should be all good 👍

https://github.com/sampotts/plyr/blob/master/src/js/plyr.js#L1771

@arrowthemes
Copy link
Contributor

Thanks heaps!

@spencer237
Copy link

@sampotts awesome bro it works
https://github.com/sampotts/plyr/blob/master/src/js/plyr.js#L1771

@sampotts
Copy link
Owner

Excellent. Sorry about the issue.

@spencer237
Copy link

@sampotts thanks again...

@adhesiv
Copy link

adhesiv commented Nov 15, 2017

Thanks for the quick fix - with holiday around the corner it's unfortunate Google felt the need to make this change without advance communication to the community regardless of it being undocumented. Let's hope we don't see anymore surprises over the next few months.

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

9 participants