Aion Mike
Aion Mike

Reputation: 1

How to Dynamically update Youtube Player videoID

I have a js function that returns a random VideoID from a channel. I want to dynamically insert this ID into the youtubeAPI's videoID parameter.

// 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
      }
    });
  }

Upvotes: 0

Views: 558

Answers (1)

Victor BJ
Victor BJ

Reputation: 11

Prueba utilizando esta linea :)

player.loadVideoById("id_video");

Upvotes: 1

Related Questions