jwplayer v7.xx _.getVideoData is not a function issue

1.7k views Asked by At

From today I have the following issue on youtube hosted videos when I want to change dynamically the video on my site.

_.getVideoData is not a function

Uncaught TypeError: _.getVideoData is not a function
at M (ssl.p.jwpcdn.com/player/v/7.12.11/provider.youtube.js:1)
at load (ssl.p.jwpcdn.com/player/v/7.12.11/provider.youtube.js:1)
at l.a (ssl.p.jwpcdn.com/player/v/7.12.11/provider.youtube.js:1)
at l.<anonymous> 
(ssl.p.jwpcdn.com/player/v/7.12.11/provider.youtube.js:1)
at P (ssl.p.jwpcdn.com/player/v/7.12.11/provider.youtube.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)

Until today it worked fine. (The jwplayer 8 version show the same issue)

3

There are 3 answers

1
funrob On BEST ANSWER

JW Player 7.12.x uses the youtube-iframe-api. The getVideoData method was removed without warning, and we would like Google to put it back to restore functionality to integrations that use it.

The source to the JW Player Youtube provider can be found and forked here:

https://github.com/jwplayer/jwplayer/blob/v7.12.x/src/js/providers/youtube.js

And this issue is being tracked in the project here:

https://github.com/jwplayer/jwplayer/issues/2525

3
jherrieven On

While you wait for word from Google, I've created a plugin to fix it in the meantime. Download it from here:

https://www.dev.powered-by-haiku.co.uk/solutions/getvideodata/code/getvideodata.js

(NOTE: You'll need to copy & paste the URL into the browser to get the code as hotlinking is not allowed)

Apply it as you would any other JW plugin:

"plugins":{
     "getvideodata.js":{}
}

EDIT: This has now been updated to cater for the "autostart":true scenario. Please note that recent versions of Chrome now block media plays that are not initiated via a user gesture, and because JW Player doesn't handle the resulting error state gracefully (when trying to autostart YouTube for example), the player will get into an apparent endless buffering state. This plugin resolves this by cancelling the autostart request on Chrome and leaves it to the user to initiate playback.

1
Douglas Rhiner On

Tried the patch plugin but get anerror: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient

UPDATE:

If you compile from source/git v7.12;

In src/js/providers/youtube.js

Replace:

var videoData = _youtubePlayer.getVideoData();
var currentVideoId = videoData && videoData.video_id;

With:

var videoData = _youtubePlayer.getVideoUrl();
videoData = videoData.split('=');
var currentVideoId = videoData[1];