【问题标题】:Youtube Autoplay on mobile not working but in browser it works移动设备上的 Youtube 自动播放不起作用,但在浏览器中它可以工作
【发布时间】:2017-11-18 23:24:39
【问题描述】:

我只是将常规的 youtube 视频嵌入到我的 html 文件中。 我使用 autoplay=1 ,它在浏览器上正常工作。 但自动播放不适用于任何手机。

你能帮忙吗?

谢谢

【问题讨论】:

    标签: php youtube autoplay


    【解决方案1】:

    `

    var player;
    
    function onYouTubePlayerAPIReady() {
        player = new YT.Player('player', {
            playerVars: {
                'autoplay': 1,
                'controls': 0,
                'autohide': 1,
                'wmode': 'opaque',
                'showinfo': 0,
                'loop': 1,
    	    'playlist': 'aF5HAF0fg6M',
    	    'fs':1
            },
            videoId: 'aF5HAF0fg6M',
            events: {
                'onReady': function(){
          player.pauseVideo();
          player.playVideo();
    	    }
            }
        });
    
    }
    
    window.onload=function() {
    };
    .video-background {
      background: #000;
      position: fixed;
      top: 0; right: 0; bottom: 0; left: 0;
      z-index: -99;
    }
    .video-foreground,.video-background iframe {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
    }
    
    @media (min-aspect-ratio: 16/9) {
      .video-foreground { height: 300%; top: -100%; }
    }
    <script src="http://www.youtube.com/player_api"></script>
    
    <div class="video-background">
    <div class="video-foreground">
    	<div id="player" ></div>
    </div>
    </div>
    
    <div>test</div>

    以下链接上的工作示例 http://demo.jawadsolutions.com/researchs/youtube/

    【讨论】:

      猜你喜欢
      • 2020-01-13
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多