YouTube JS代码 - 100%宽度,静音和锁定

时间:2015-08-12 11:39:32

标签: javascript youtube

我有JS代码,必须将其转换为100% width800px heightpointer-events: none;是否有机会将此代码添加到此代码中? 此代码将youtube视频更改为静音。

<!-- 1. The <div> tag will contain the <iframe> (and video player) -->  
<div id="player"></div>
<script>      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
      tag.src = "http://www.youtube.com/player_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubePlayerAPIReady() {
        player = new YT.Player('player', {
          playerVars: { 'autoplay': 1, 'controls': 0,'loop': 1,'playlist': '2oqCAmfc0D0','autohide':1,'showinfo': 0,'disablekb': 1,'rel': 0,'wmode':'opaque' },
          videoId: '2oqCAmfc0D0',
width: '100%',
          events: {
            'onReady': onPlayerReady}
        });
      }

      // 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
        event.target.mute();
      }
</script>

1 个答案:

答案 0 :(得分:0)

你的意思是这样的吗? JSFiddle Example

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
    char *read[100];
    char *ch, *back;
    int i;

    ch = read;

    printf("Enter a sentence and get it reversed: ");
    while (getchar() != '\n') {
        *ch = getchar();
        ch++;
    }

    for (back = ch; back != read; back--) {
        printf("%s",*back);
    }

    return 0;
}

警告,指针事件与旧IE有一些兼容性问题。见caniuse

执行相同操作的另一种方法是使用可见性:隐藏的重叠div。或者是一个覆盖透明的div。