<视频>在 Firefox 上停止时屏幕很快就会黑屏视频>
我有一个简单的网页,其中包含 HTML 5 元素和简单的 Javascript,用于创建在视频之间切换的链接并使每个视频在预定时间停止。
它在 Chrome 94、Edge 99 和 Vivaldi 4.3(我使用的是 Windows 10)上似乎工作正常。
然而,在我的 Firefox 91.7esr 中,当视频停止时(在停止时间或结束时),屏幕通常会黑屏约 1 秒。 之后,一切正常进行。
整个屏幕都变黑了,不仅仅是 Firefox 窗口或页面上的 元素。
这种情况发生的频率大约有三分之一是不规则的(在视频开始时发生的频率也低得多)。
为什么?
网页和视频都是本地文件。
无论 Firefox 中的硬件加速打开还是关闭,都会出现该效果。
重启后也会发生这种情况。
这是相应的代码:
<!DOCTYPE html>
<html>
<body>
<video id="pomalevi-video" height=540 controls>
Your browser does not support the video tag.
</video>
<br>
<button onclick="pmlv_speed(pmlv_video, 1.0)">1.0x</button>
<button onclick="pmlv_speed(pmlv_video, 1.7)">1.7x</button>
<button onclick="pmlv_speed(pmlv_video, 2.0)">2.0x</button>
<p onclick='pmlv_switch_to(1)'>start video 1</p>
<p onclick='pmlv_switch_to(2)'>start video 2</p>
<script>
var pmlv_video = document.getElementById("pomalevi-video")
var pmlv_video_idx = 1
var pmlv_stoptimes = [[5.1, 8.5, 11.9], [17.0, 20.4]] // list of list of floats: stop times in seconds
function pmlv_pause_at_stoptimes() {
for (var t of pmlv_stoptimes[pmlv_video_idx-1]) {
if(pmlv_video.currentTime >= t && pmlv_video.currentTime <= t+0.5) {
pmlv_video.pause()
pmlv_video.currentTime += 0.5
}
}
}
function pmlv_speed(obj, factor) {
obj.playbackRate = factor
}
function pmlv_switch_to(i, play=true) {
pmlv_video.src = "v" + i + ".mp4"
pmlv_video_idx = i // select the relevant stoptimes
pmlv_video.load()
if (play) {
pmlv_video.play()
}
}
pmlv_video.addEventListener("timeupdate", pmlv_pause_at_stoptimes)
pmlv_switch_to(1, false)
</script>
</body>
</html>
I have a simple webpage with an HTML 5 <video>
element and simple Javascript for creating links to switch between videos and for making each video stop at predetermined times.
It appears to work fine on Chrome 94, Edge 99, and Vivaldi 4.3 (I am on Windows 10).
In my Firefox 91.7esr, however, when the video stops (at a stop time or at the end), the screen will often black out for about 1 second.
After that, everything continues normally.
It is the entire screen that blacks out, not only the Firefox window or the <video>
element on the page.
This happens irregularly about one third of the times (and much less frequently also when the video starts).
Why?
The web page and the videos are local files.
The effect occurs no matter whether hardware acceleration is on or off in Firefox.
It happens also after a reboot.
Here is the respective code:
<!DOCTYPE html>
<html>
<body>
<video id="pomalevi-video" height=540 controls>
Your browser does not support the video tag.
</video>
<br>
<button onclick="pmlv_speed(pmlv_video, 1.0)">1.0x</button>
<button onclick="pmlv_speed(pmlv_video, 1.7)">1.7x</button>
<button onclick="pmlv_speed(pmlv_video, 2.0)">2.0x</button>
<p onclick='pmlv_switch_to(1)'>start video 1</p>
<p onclick='pmlv_switch_to(2)'>start video 2</p>
<script>
var pmlv_video = document.getElementById("pomalevi-video")
var pmlv_video_idx = 1
var pmlv_stoptimes = [[5.1, 8.5, 11.9], [17.0, 20.4]] // list of list of floats: stop times in seconds
function pmlv_pause_at_stoptimes() {
for (var t of pmlv_stoptimes[pmlv_video_idx-1]) {
if(pmlv_video.currentTime >= t && pmlv_video.currentTime <= t+0.5) {
pmlv_video.pause()
pmlv_video.currentTime += 0.5
}
}
}
function pmlv_speed(obj, factor) {
obj.playbackRate = factor
}
function pmlv_switch_to(i, play=true) {
pmlv_video.src = "v" + i + ".mp4"
pmlv_video_idx = i // select the relevant stoptimes
pmlv_video.load()
if (play) {
pmlv_video.play()
}
}
pmlv_video.addEventListener("timeupdate", pmlv_pause_at_stoptimes)
pmlv_switch_to(1, false)
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题与我的 HTML 或 Javascript 无关。
相反,这似乎是硬件问题:
首先通过Icy Box IB-DK2403-C 扩展坞连接到我的笔记本电脑
使用 USB-C 并通过 HDMI 进行连接。
问题依然存在,但是被黑掉的东西依然存在
外部监视器,而不是具有 Firefox 窗口的内部监视器。
通过扩展坞,问题就消失了。
还有:我看到 Windows 通知时屏幕黑了
播放了声音。
在
元素的控件中,因此显然音频和
视频启动或停止可能会导致停电。诡异的。
我没有更快理解这一点的原因是
一天后我就开始测试我的应用程序
我已经开始使用扩展坞了。
我还没有注意到其他时间发生的停电。
The problem has nothing to do with my HTML or Javascript.
Rather, it appears to be a hardware issue:
to my notebook via, first an Icy Box IB-DK2403-C docking station
using USB-C and from there via HDMI.
the problem still occurs, but what is blacked out is still
the external monitor, not the internal one having the Firefox window.
through the docking station, the problem disappears.
as well: I have seen the screen black out when Windows notification
sounds were played.
in the
<video>
element's controls, so apparently both audio andvideo starting or stopping can produce a blackout. Weird.
The reason why I did not understand this more quickly is
that I started testing my application only one day after
I had started using the docking station.
I had not yet noticed the blackouts that occurred at other times.