TypeError:player.b未定义。我该如何解决?

时间:2020-05-10 05:24:51

标签: javascript youtube-api

要解决此问题,需要在代码中进行哪些调整?

代码: https://jsfiddle.net/0bnrg3k1/2/

    function onPlayerStateChange(event) {
    const player = event.target;
    const playerVars = player.b.b.playerVars;
    if (playerVars.loop && event.data === YT.PlayerState.ENDED) {
      player.seekTo(playerVars.start);
    }
  }

1 个答案:

答案 0 :(得分:1)

您需要使用player.b.b.playerVars来代替player.g.g.playerVars

function onPlayerStateChange(event) {
  const player = event.target;
  const playerVars = player.g.g.playerVars;
  if (playerVars.loop && event.data === YT.PlayerState.ENDED) {
    player.seekTo(playerVars.start);
  }
}