简体   繁体   English

更改Vimeo播放器背景色

[英]Change Vimeo player background color

Sorry, I'm not sure why this is so hard. 抱歉,我不确定为什么这么难。 Is it possible to change the background color from black to white. 是否可以将背景颜色从黑色更改为白色。

Fiddle link: http://jsfiddle.net/nicktest2222/MF9Q2/2/ 小提琴链接: http : //jsfiddle.net/nicktest2222/MF9Q2/2/

<iframe src="https://player.vimeo.com/video/86019637?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff&amp;autoplay=1" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

According to the link below Vimeo forum thread, this cannot be done. 根据Vimeo论坛主题下面的链接,此操作无法完成。

http://vimeo.com/forums/topic:109827 http://vimeo.com/forums/topic:109827

A workaround is to hide the player until it has been preloaded and ready. 一种解决方法是隐藏播放器,直到播放器已预加载并准备就绪。

<iframe id="my-video" class="my-video" src="https://player.vimeo.com/video/126091504?api=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

Set your video to be hidden by default 将您的视频设置为默认隐藏

<style>
  .my-video {
    visibility: hidden;
  }
  .my-video.ready {
    visibility: visible;
  }
</style>

Then preload the video and listen for it to be ready: 然后预加载视频并收听准备就绪:

<script>
var player = $('#my-video');
var playing = false;

function onMessageReceived(e) {
  // Handle messages from the vimeo player only
  if (!(/^https?:\/\/player.vimeo.com/).test(e.originalEvent.origin)) {
    return false;
  }

  var data = JSON.parse(e.originalEvent.data);

  switch (data.event) {
    case 'ready':
      onReady();
      break;

    case 'playProgress':
      if(!playing) {
        post('pause');
      } else {
        // wait for video to be ready before showing it to avoid flicker
        setTimeout(function() {
          player.addClass('ready');
        }, 100);
      }
      break;
}

function post(action, value) {
  // Helper function for sending a message to the player
  var data = {
    method: action
  };

  if(value) {
    data.value = value;
  }

  var message = JSON.stringify(data);
  player[0].contentWindow.postMessage(data, '*');
}


function onReady() {
  //add playProgress listener
  post('addEventListener', 'playProgress');

  //preload video
  post('play');
}

$(window).on('message', onMessageReceived);
</script>

2 years late...but I wound up here looking for an answer to the same question. 迟到了2年...但是我最后在这里寻找相同问题的答案。 Eventually got it figured out, try something like this: 最终弄明白了,尝试这样的事情:

<style>
    .embed-container {
        position: relative;
        padding-bottom: 56.25%;
        height: 0;
        overflow: hidden;
        max-width: 100%;
    } 
    .embed-container iframe,
    .embed-container object,
    .embed-container embed { 
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%; 
     }
</style>
<div class='embed-container'>
    <iframe src='http://player.vimeo.com/video/66140585' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM