在UC浏览器中重叠html5视频播放器问题

时间:2022-01-07 18:58:44

Is that possible to overlap div element over HTML5 video player in UC browser.

可以在UC浏览器中将HTML元素重叠到HTML5视频播放器上。

<div class="test">
  <div class="goover"></div>
  <video width="400" controls>
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">`
    Your browser does not support HTML5 video.
  </video>
</div>

fiddle

2 个解决方案

#1


5  

I assume here you want your div to be the same size as your video. This thread has a pretty nice answer for you.

我假设您希望您的div与视频大小相同。这个帖子有一个很好的答案。

setInterval(function() {
  var width = $("#vid").width();
  var height = $("#vid").height();
  $(".goover").css({
    'width': width,
    'height': height
  });
}, 10);
.test{
   position:relative
 }

.goover{
  width: 2px;
  height: 2px;
  border: solid 2px red;
  background: rgba(255,0,0,0.8);
  position: absolute;
  z-index: 10;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="test">
  <div class="goover"></div>
  <video width="400" id="vid" controls autoplay>         
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    Your browser does not support HTML5 video.
  </video>
</div>

I modified the snippet a little bit to match yours better. And I also put a little of transparency in the red background so you can see that the div is overlapping over the video.

我修改了一些片段以便更好地匹配你的片段。而且我还在红色背景中放了一点透明度,这样你就可以看到div在视频上重叠了。

EDIT :

Tested on UC-Browser V6.1.2015.1007 (latest release for now) and it works just fine.

在UC-Browser V6.1.2015.1007上测试(目前是最新版本),它运行得很好。

EDIT2 :

The controls weren't hidden in UC-Browser, fixed it in css by adding the z-index.

控件未隐藏在UC浏览器中,通过添加z-index将其修复为css。

EDIT3 :

I've added the autoplay attribute on the video tag to see it working while in play mode.

我在视频标签上添加了自动播放属性,以便在播放模式下看到它正常工作。

#2


0  

How about this:
https://jsfiddle.net/zpjsz8g8/1/

怎么样:https://jsfiddle.net/zpjsz8g8/1/

.test { position: relative }
.goover {
    position: absolute;
    background: #ff0000;
    top: 0;
    bottom: 0;
    left: 0;
    /*right:0px*/
    width: 400 px;
    z - index: 1;
}

or

var videoContainer = document.getElementsByTagName('video')[0];
var goover = document.getElementsByClassName('goover')[0];

goover.style.height = videoContainer.getBoundingClientRect().height + 'px';
goover.style.width = videoContainer.getBoundingClientRect().width + 'px'

#1


5  

I assume here you want your div to be the same size as your video. This thread has a pretty nice answer for you.

我假设您希望您的div与视频大小相同。这个帖子有一个很好的答案。

setInterval(function() {
  var width = $("#vid").width();
  var height = $("#vid").height();
  $(".goover").css({
    'width': width,
    'height': height
  });
}, 10);
.test{
   position:relative
 }

.goover{
  width: 2px;
  height: 2px;
  border: solid 2px red;
  background: rgba(255,0,0,0.8);
  position: absolute;
  z-index: 10;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="test">
  <div class="goover"></div>
  <video width="400" id="vid" controls autoplay>         
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    Your browser does not support HTML5 video.
  </video>
</div>

I modified the snippet a little bit to match yours better. And I also put a little of transparency in the red background so you can see that the div is overlapping over the video.

我修改了一些片段以便更好地匹配你的片段。而且我还在红色背景中放了一点透明度,这样你就可以看到div在视频上重叠了。

EDIT :

Tested on UC-Browser V6.1.2015.1007 (latest release for now) and it works just fine.

在UC-Browser V6.1.2015.1007上测试(目前是最新版本),它运行得很好。

EDIT2 :

The controls weren't hidden in UC-Browser, fixed it in css by adding the z-index.

控件未隐藏在UC浏览器中,通过添加z-index将其修复为css。

EDIT3 :

I've added the autoplay attribute on the video tag to see it working while in play mode.

我在视频标签上添加了自动播放属性,以便在播放模式下看到它正常工作。

#2


0  

How about this:
https://jsfiddle.net/zpjsz8g8/1/

怎么样:https://jsfiddle.net/zpjsz8g8/1/

.test { position: relative }
.goover {
    position: absolute;
    background: #ff0000;
    top: 0;
    bottom: 0;
    left: 0;
    /*right:0px*/
    width: 400 px;
    z - index: 1;
}

or

var videoContainer = document.getElementsByTagName('video')[0];
var goover = document.getElementsByClassName('goover')[0];

goover.style.height = videoContainer.getBoundingClientRect().height + 'px';
goover.style.width = videoContainer.getBoundingClientRect().width + 'px'