Questions about the YouTube player_api code


#122

No - the addVideo line in the init function.


#123

Remove the whole thing?
addVideo(playerVars, opts);


#124

No. Here’s what I said just a short time ago about it.


#125

Got it:
https://jsfiddle.net/hzyrfkwb/418/


#126

The plan is to give width/height information to loadPlayer, which gives it to videoPlayer’s init, which gives it to addVideo.

loadPlayer is our next target.

The most correctly structured way of doing this is by using the following:

loadPlayer({
  target: ".jacketc",
  width: 600,
  height: 338,
  playerVars: {
    start: 900,
    end: 1200
  }
});

If you’re okay with that, we’ll update that and get loadPlayer working with that too.


#127

got it here:
https://jsfiddle.net/hzyrfkwb/419/


#128

The loadPlayer function instead of using two parameters, needs to change to have only the one parameter of opts.
Where containerSelector is used in the loadPlayer function, rename that to opts.target
The initPlayer function needs to update opts, with opts.video = wrapper.querySelector(".video");
And the rest of the initPlayer function just needs to be videoPlayer.init(opts);


#129

A bunch of errors came up:
https://jsfiddle.net/hzyrfkwb/420/


#130

I got this far:
https://jsfiddle.net/hzyrfkwb/422/


#131

Okay, one at a time.

That function still has two parameters, neither of which is entirely correct, when it must only be one.

containerSelector is still being used in the function. This instruction was mistakenly done to the function parameters instead.

This doesn’t seem to have been done at all.

And this hasn’t been done either.

Overall this is a very poor showing, and much more effort is required to get things right.


#132

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

PlayerVars is in gray?


#133

Where?


#134

https://jsfiddle.net/hzyrfkwb/424/

  function initPlayer(wrapper) {
   videoPlayer.init(opts);
      opts.video = wrapper.querySelector(".video"):
      playerVars
    };
  }

It’s the braces


#135

Okay, back to the list.

Done.

Done.

This needs to be the first thing in the initPlayer function, not hiding in the videoPlayer code.

Not yet achieved.


#136

I’m messing this up:


  function initPlayer(wrapper) {
  opts.video = wrapper.querySelector(".video");
   videoPlayer.init(opts);
      
      playerVars
      }

#137

There should be nothing else after the videoPlayer line. That playerVars should be deleted, as it’s already included in the opts object.


#138

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

The Grid player is now broken.

TypeError: cover is null


#139

Let’s get that working then. The loadPlayer commands for the grid videos need to be updated in the same way as for the single player.

Before:

loadPlayer(".playa", {
  start: 900,
  end: 1200
});

After:

loadPlayer({
  target: ".playa",
  playerVars: {
    start: 900,
    end: 1200
  }
});

#140

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


#141

We now have width and height coming in from outside of the videoPlayer code, via the init function and through to the addVideo function.

From there, we can now use opts.width or if it’s not defined, 198 instead.

width: opts.width || 198,
height: opts.height || 198,