如何动态更新Youtube Player videoID

问题描述 投票:0回答:1

我有一个js函数,该函数从频道返回随机的VideoID。我想将此ID动态插入youtubeAPI的videoID参数中。

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
  var player;
  function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
      height: '390',
      width: '640',
      videoId: <<INSERT RETURN OF FUNCTION HERE>>
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
      }
    });
  }
javascript youtube-api youtube-data-api youtube-javascript-api youtube-iframe-api
1个回答
1
投票

[Prueba utilizando esta linea :)

© www.soinside.com 2019 - 2024. All rights reserved.