2
votes
     <div id="ytplayer"></div>
    <script>
        // Load the IFrame Player API code asynchronously.
        var tag = document.createElement('script');
        tag.src = "https://www.youtube.com/player_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

        // Replace the 'ytplayer' element with an <iframe> and
        // YouTube player after the API code downloads.
        var player;
        function onYouTubePlayerAPIReady() {
            player = new YT.Player('ytplayer', {
                height:'390',
                width:'640',
                videoId:'A_aYVs_zFA8',
                events:{
                    'onReady':onPlayerReady,
                    'onStateChange':onPlayerStateChange
                }
            });
        }

        function onPlayerReady(event) {
            _isPlayerReady = true;
        }
        function onPlayerStateChange(event) {
            switch (event.data) {
                case YT.PlayerState.ENDED:
                $j  = jQuery.noConflict();
                $j(".vid-flow").hide();
                ShowCustomDialog();
                    break;
                case YT.PlayerState.PLAYING:
                    break;
                case YT.PlayerState.PAUSED:
                    break;
                case YT.PlayerState.BUFFERING:
                    break;
                case YT.PlayerState.CUED:
                    break;
                default:
                    break;
            }
        }


    </script>

In JavaScript I want to load a youtube player on 'ytplayer' div. I am looking on this https://developers.google.com/youtube/iframe_api_reference#Operations Somebody know how I can remove the name of video.

I tried to get the iframe but if I do iframe my js code will not work. So someone have option to remove the name which is shown In top of youtube video embed.

3
I would doubt this would be possible. For various reasons other than why.Leeish
I can do it in iframe by placing "showinfo=0". Don't know how to do same in javascript.user1978003
@Leeish it is possible -_- :D , check my answerYusaf Khaliq
I don't see the name changed, it's just removed. I apologize, for some reason, maybe it was a different thread I thought we were trying to "change" the name of the video.Leeish

3 Answers

10
votes

http://jsfiddle.net/jXWtE/

function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
        height: '390',
        width: '640',
        videoId: 'A_aYVs_zFA8',
        playerVars: {
            'showinfo': 0
        },
        events: {
            'onReady': onPlayerReady,
                'onStateChange': onPlayerStateChange
        }
    });
}
3
votes

Yusaf Khaliq has the correct answer, but a way to force the embed tag to accept extra arguments after the videoID by changing

videoId:'A_aYVs_zFA8',

to

videoId:'A_aYVs_zFA8?showinfo=0&',

You should be able to string as many arguments as you want in this way, just separate them each by &.

1
votes

Unfortunately, the showinfo attribute was deprecated as of September 25, 2018. This means that there is no supported mechanism to disable the information at the top of the video anymore using their API.

https://developers.google.com/youtube/player_parameters#showinfo