plyr: getVideoData is not a function

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

https://github.com/lunametrics/youtube-google-analytics/issues/36

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 12
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Excellent. Sorry about the issue.

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

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

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.

Thanks heaps!