Questions about the YouTube player_api code


#102

Like this:
const videoId = opts.video.opts.video.dataset.id;("data-id")


#103

No, not like that. You have too many things there.

After the equals sign you should just have opts.video.dataset.id;


#104

Got it yellow dot:
https://jsfiddle.net/hzyrfkwb/408/


#105

What do you mean by “yellow dot”?


#106

This:
image


#107

Yes, that shouldn’t be there. You have more text after the equals sign than what was instructed.


#108

Fixed??
https://jsfiddle.net/hzyrfkwb/409/


#109

Okay. Looking down through the addVideo function, the next piece to update is the Object.assign line.

Instead of desiredPlayerVars, we want that to be opts.playerVars instead.


#110

Top and bottom?

  function addVideo(video, opts.playerVars, opts) {
  
  const videoId = opts.video.dataset.id;
    const defaultPlayerVars = {
      autoplay: 1,
      controls: 1,
      showinfo: 1,
      rel: 0,
      iv_load_policy: 3,
      cc_load_policy: 0,
      fs: 0,
      disablekb: 1
    };
    const playerVars = Object.assign(defaultPlayerVars, opts.playerVars);
    players.push(new YT.Player(video,{

#111

On the next line is a video keyword, that we want to be opts.video instead.


#112

There’s a red dot now:
https://jsfiddle.net/hzyrfkwb/411/

function addVideo(video, opts.playerVars, opts) {


#113

No, you don’t change the function parameters. Put that back.

I explicitly instructed you to only change the one on the Object.assign line.


#114

fixed:
https://jsfiddle.net/hzyrfkwb/413/


#115

Here:
https://jsfiddle.net/hzyrfkwb/414/


#116

Okay, let’s go back to the line just below the Object.assign line. There’s a video keyword that needs to be updated to be opts.video instead.


#117

I did Here:
https://jsfiddle.net/hzyrfkwb/414/


#118

Good one. We can now remove the first two parameters from addVideo, both in the function declaration and in the init function where it’s used, so that only opts is used.


#119

Which didn’t I do?
https://jsfiddle.net/hzyrfkwb/415/


#120

The one in the init function.


#121

In here?
const playerVars = opts.playerVars || {};