YouTube embed showinfo has been deprecated

后端 未结 8 2091
抹茶落季
抹茶落季 2020-12-10 12:06

We are using a YouTube video on our website as a hero banner.

However few days ago it started showing it\'s title, watch later button and a share button. We were abl

相关标签:
8条回答
  • 2020-12-10 12:13

    Not having 'rel=0' is irritating, but there is a work around. If you work with the IFrame API, (as opposed to embedding an iframe ex http://youtu.be/?videoIDxxx...) you can get the event for the stopping (completing) of the video, then cue up the video by ID into the player. See https://developers.google.com/youtube/iframe_api_reference#Playback_controls for reference to the basic player.

     
    ....
    
    <div id="player1"></div>
    
    <script type="text/javascript">
    var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    
    var player ;
    
    function onYouTubeIframeAPIReady()
        {
        player = new YT.Player('player1', 
            { 
            videoId: 'YourVideoId',
            events: {
                'onStateChange': onPlayerStateChange
                 }
            });
    
        }; // onYOuTubeIframeAPIReady
        		
    function onPlayerStateChange(event)
        { 
        // Alt approach //if( event.data  == 0){ location.reload()}
        if( event.data  == 0)
            { player.cueVideoById({videoId:'YourVideoID',
                                   suggestedQuality: 'hd720'})
            };
        } 
    
         </script>

    0 讨论(0)
  • 2020-12-10 12:15

    Directly from show info

    Note: This is a deprecation announcement for the showinfo parameter. In addition, the behavior for the rel parameter is changing. Titles, channel information, and related videos are an important part of YouTube’s core user experience, and these changes help to make the YouTube viewing experience consistent across different platforms.

    The behavior for the rel parameter is changing on or after September 25, 2018. The effect of the change is that you will not be able to disable related videos. However, you will have the option of specifying that the related videos shown in the player should be from the same channel as the video that was just played.

    It clearly states that this is something they consider to be part of the cor youtube experience. There is no suggestion of a workaround or a new parameter that you could send to archive the old results. They are removing it. If you tried to force it out using javascript and css i would almost suggest you are against the TOC which states your not allowed to change that display. People should know you are showing something from YouTube

    0 讨论(0)
  • 2020-12-10 12:15

    Well, I just noticed it as well. It sucks and ruins the aesthetics. So I just did a

    header {
        /* remove when YT got its brain back */
        margin-top: -56px;
    }
    

    while hoping that they'll re-add showinfo=0 again.

    0 讨论(0)
  • 2020-12-10 12:16

    The solution I found aesthetically most pleasing is to lay a high res thumbnail over the video and hide it at hover. This also deals with the problem that the youtube preview is low res and looks cheap in my opinion.

    Check it out here: http://jsfiddle.net/d9D9E/1/

    Had to write code in order to show the js fiddle :/

    .video-thumbnail{
        z-index:300;
        position:absolute;
        top:0;
        left:0;
        width:100%;
    }
    
    .video-thumbnail:hover{
        display:none;
    }
    
    0 讨论(0)
  • 2020-12-10 12:22

    What about this. Yeah this will zoom the video.

    iframe {
      transform:scale(1.4);
    }
    
    0 讨论(0)
  • 2020-12-10 12:25

    If you need to hide the info, ideally go for Vimeo pro (which properly supports a no info embed),

    Otherwise there is a simple workaround:

    https://jsfiddle.net/10ov5hgw/1/

    It cuts off the bottom & top 60px of the iframe, but via overflow rather than a gross looking black bar on top, so video still looks fullscreen the entire time (and barely any of the video is cutout if you force 720) ,

    This hack supports having to support mobile views aswell, without heavily impacting the visible area of the video.

    .video-container{
      width:100vw;
      height:100vh;
      overflow:hidden;
      position:relative;
    }
    .video-container iframe,{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
    .video-container iframe, {
      pointer-events: none;
    }
    .video-container iframe{
      position: absolute;
      top: -60px;
      left: 0;
      width: 100%;
      height: calc(100% + 120px);
    }
    .video-foreground{
      pointer-events:none;
    }
    
    <div class="video-container" >
        <div class="video-foreground">
            <iframe
                   src="https://www.youtube.com/embed/W0LHTWG-UmQ?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ&mute=1"
                   frameBorder="0" allowFullScreen>
    
            </iframe>
        </div>             
    </div>                                        
    
    0 讨论(0)
提交回复
热议问题