英文:
How do I move the videojs control bar out of the video area or duplicate a videojs control bar?
问题
我使用了一个画布元素来对视频进行像素化处理,通过覆盖在视频上实现。但是画布元素会覆盖控制栏。所以是否有办法将控制栏移出视频区域,或者隐藏原始的控制栏并复制一个新的video.js控制栏?
视频区域内的控制栏](https://i.stack.imgur.com/ZykMJ.png)
顺便问一下,在前端实现视频像素化处理,这是否是最佳实践?
英文:
I used a canvas element to pixelate a video by covering it on the video. But the canvas element will cover the control bar. So is there a way to move the control bar out of the video area or hide the original one and duplicate a new videojs control bar?
control bar in the video area](https://i.stack.imgur.com/ZykMJ.png)
By the way, is this the best practice to pixelate a video in front end?
答案1
得分: 1
我会将属性 pointer-events: none 分配给 canvas,这样合并将无缝进行。
<canvas style="pointer-events:none">...
这样,您的 canvas 将仅作为过滤器,无法拦截点击或其他任何操作。
至于另一个问题,没有强制性的最佳做法,因为这有点主观,但对于更复杂的效果,这是一种常用的技巧。
编辑:这里有一个示例来移动自定义控制栏。
https://github.com/videojs/video.js/issues/2857
我进行了一些快速测试。您可以使用 CSS 来移动控制栏。
.vjs-control-bar
{
position: relative;
top: 300px;
}
英文:
I would assign the property pointer-events: none to the canvas so the merge will be seamless.
<canvas style="pointer-events:none">...
This way, your canvas will be just a filter, with no way of intercepting a click or anything else.
For the other question. No forcibly best practice as it's a bit subjective, however, for more complex effects, it is a used technic.
EDIT: There's an example here to move a custom control bar.
https://github.com/videojs/video.js/issues/2857
I did some quick tests. You can move the control bar with CSS
.vjs-control-bar
{
position: relative;
top: 300px;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论