1
votes

I want to embed a gaming live stream on my website and play it using JavaScript.

Using the YouTube IFrame Player API, I can dynamically embed and control YouTube videos. YouTube Gaming has its own version of the player that links to gaming.youtube.com instead of www.youtube.com. But there's no mention of how to make the API use it.

I tried using https://gaming.youtube.com/iframe_api, but it doesn't exist.

How do I embed a YouTube Gaming video with the IFrame API?

2
Why do you need javascript in particular ?Hornth
I need to use JavaScript because I want the video to auto-play muted.Timothy003

2 Answers

0
votes

You don't need to use gaming.youtube.com. www.youtube.com works !

0
votes

I pass an undocumented host property to the constructor. It seems to work fine.

var player;
function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    host: "https://gaming.youtube.com",
    videoId: 'M7lc1UVf-VE',
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
    }
  });
}