0

I have seen this script to auto-mute video's from youtube embedded on a site:

How do I automatically play a Youtube video (IFrame API) muted?

The code is available on fiddle:

http://jsfiddle.net/9RjzU/3/

However I would like to know what to add to this code to prevent related videos appearing?

Thanks Azzam

Community
  • 1
  • 1
Azzam
  • 5
  • 5
  • Possible duplicate of [Youtube Javascript API - disable related videos](https://stackoverflow.com/questions/13418028/youtube-javascript-api-disable-related-videos) – Maximillian Laumeister Dec 06 '18 at 01:21

1 Answers1

1

In your situation, all that is needed is to add 'rel': 0 to the PlayerVars parameters, like so:

function onYouTubePlayerAPIReady() {

    player = new YT.Player('player', {

        playerVars: { 
                      'autoplay': 1, 
                      'controls': 1,
                      'autohide': 1,
                      'wmode': 'opaque',
                      'rel': 0 
                    },

        videoId: 'JW5meKfy3fY',

        events: { 'onReady': onPlayerReady }
    });
}

You might also be interested in the full list of parameters available for the YouTube iframe API, found here: https://developers.google.com/youtube/player_parameters#Parameters

RobotZombieLord
  • 188
  • 1
  • 11