5

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)

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
janosdupai
  • 519
  • 1
  • 5
  • 16
  • My function for changing the video: function videotValt(newfile){ var windowWidth = window.innerWidth; var windowHeight = window.innerHeight; jwplayer("videoPosition").setup({ file: newfile, autostart: true, width:windowWidth, height:windowHeight,}); playerInitialized = true; $(".loading").show(); setTimeout("videoCheck2()", 500); } – janosdupai Nov 14 '17 at 09:39
  • We started seeing this problem as well as early as a few days ago. We juse jwplayer 7.x.x as well. They have dropped maintenance for the youtube plugin a year ago and this may just be the death throws of the plugin. Which sucks. – Erik Donohoo Nov 14 '17 at 15:28
  • The issue is with YouTube having removed the undocumented "getVideoData" method from the API. It's affecting a number of YouTube "wrapping" players. This has happened in the past, and it has then come back just as quietly as it disappeared! I do have a fix, but it depends on your specific implementation as to how you would apply it. Are you able to share links to your problem pages? – jherrieven Nov 14 '17 at 17:26
  • JW 8 does not support Youtube video. – funrob Nov 14 '17 at 22:15

3 Answers3

1

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

funrob
  • 619
  • 6
  • 13
  • It looks like YouTube restored the getVideoData method on Nov 16 and this is no longer an issue. – funrob Nov 21 '17 at 03:39
1

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];
  • That's nothing to do with the plugin - that message commonly occurs with JW players implementation under 'normal' circumstances. – jherrieven Nov 15 '17 at 09:09
0

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.

jherrieven
  • 425
  • 2
  • 5
  • hi, can you tell me how to use your plugin. I have add the script right below the jwplayer.js and my code now:: jwplayer("myElement").setup({ autostart: true, file: video,"plugins":{ "jwplayer/getvideodata.js":{} }, width: "100%", aspectratio: "16:9", }); – Salih K Nov 15 '17 at 10:29
  • @SalihK - You don't need to include the script explicitly, you just add it to the setup block as you have done - but make sure the "jwplayer/getvideodata.js" is resolving to the downloaded file on your server. – jherrieven Nov 15 '17 at 10:51
  • @SalihK - I have just noticed that this doesn't work with "autostart":true on some occasions - this is due to there not being a clean way to hook into the originating YouTube instance, and so a race condition is occurring. If you set "autostart" to false in the short term, I'll look at ways to resolve this. – jherrieven Nov 15 '17 at 10:58