Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to hide YouTube Branding with iFrame API

I am using YouTube iFrame API to load videos in my custom player (javascript player). I have a requirement to hide the Youtube branding however on iOS devices, it shows the logo with below parameters:

playerVars:
{
    'fs':1,
    'autoplay' : 0,
    'showinfo' : 0,
    'rel' : 0,
    'controls' : videoControls,
    'cc_load_policy' : 0,
    'color':'white',
    'modestbranding' : 1,
    'iv_load_policy' : 3,
    'loop':inv_loop,
    'wmode': 'transparent',
    'playlist':playlist,
    'playsinline':1
}

If I keep "showinfo" to 1, it hides the logo however it shows the video title, share and watch later icons along with ads.

is there any way to hide both (youtube logo and uploader info with ads) with iFrame API?

Thanks!

like image 883
Vipul Avatar asked Jan 19 '26 19:01

Vipul


1 Answers

I hide everything except play/pause button.

I manage to do this with negative margins.

Check the code below -

<!DOCTYPE html>
<html>
    <style type="text/css">
        #offset{
            position: absolute;
            top: -300px;
            bottom: -300px;
            right: 0;
            left: 0;
            background-color: black;
            z-index: 12;
        }

        #payer-container{
            height: 450px;
            width: 800px;
            overflow: hidden;
            position: relative;
            z-index: 1;
        }

        
    </style>

    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <script src="https://www.youtube.com/iframe_api"></script>
    </head>

    <body>
        <div id="payer-container">
            <div id="offset">
                <div id="youTubePlayerDOM"></div>
            </div>
        </div>
    </body>

    <script type="text/javascript">
        
        var player;

        function onYouTubeIframeAPIReady() {

            
            player = new YT.Player('youTubePlayerDOM', {
                height: '100%',
                width: '100%',
                playerVars: {
                    "autoplay": 0,
                    "controls": 0,
                    "enablejsapi": 1,
                    "video_id": "QswsUQNDW_U"
                }
            });
        }

    </script>
</html>

Note:

  • You should have to create controllers manually if needed.
  • The aspect ratio of the video is fixed.
like image 110
Shubham Gupta Avatar answered Jan 21 '26 09:01

Shubham Gupta