<视频>在 Firefox 上停止时屏幕很快就会黑屏

发布于 2025-01-14 18:40:11 字数 2135 浏览 2 评论 0原文

我有一个简单的网页,其中包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

依 靠 2025-01-21 18:40:12

该问题与我的 HTML 或 Javascript 无关。
相反,这似乎是硬件问题

  • 问题发生在连接的外部显示器上
    首先通过Icy Box IB-DK2403-C 扩展坞连接到我的笔记本电脑
    使用 USB-C 并通过 HDMI 进行连接。
  • 当我在笔记本的内部屏幕上播放视频时,
    问题依然存在,但是被黑掉的东西依然存在
    外部监视器,而不是具有 Firefox 窗口的内部监视器。
  • 如果我将显示器直接连接到笔记本的 HDMI 输出,而不是
    通过扩展坞,问题就消失了。
  • 此外,该设置似乎还对音频开始/停止敏感
    还有:我看到 Windows 通知时屏幕黑了
    播放了声音。
  • 视频仍然产生关闭声音的效果
    元素的控件中,因此显然音频和
    视频启动或停止可能会导致停电。诡异的。
  • 为什么其他浏览器不受此问题的影响?不知道。 (欢迎提示!)

我没有更快理解这一点的原因是
一天后我就开始测试我的应用程序
我已经开始使用扩展坞了。
我还没有注意到其他时间发生的停电。

The problem has nothing to do with my HTML or Javascript.
Rather, it appears to be a hardware issue:

  • The problem occurred on an external monitor that is connected
    to my notebook via, first an Icy Box IB-DK2403-C docking station
    using USB-C and from there via HDMI.
  • When I play the video on the internal screen of the notebook,
    the problem still occurs, but what is blacked out is still
    the external monitor, not the internal one having the Firefox window.
  • If I connect the monitor to the notebook's HDMI output directly, rather than
    through the docking station, the problem disappears.
  • Furthermore, the setup also appears to be sensitive to audio start/stop
    as well: I have seen the screen black out when Windows notification
    sounds were played.
  • But the video still produces the effect with the sound turned off
    in the <video> element's controls, so apparently both audio and
    video starting or stopping can produce a blackout. Weird.
  • Why the other browsers are immune to the problem? No idea. (Hints welcome!)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文