nginx - Videojs - 流未运行时隐藏错误

标签 nginx http-live-streaming video.js live-streaming hls.js

我已经设置了 videojs 播放器并获得了一个 HLS 流以通过 OBS 传输到播放器。当 OBS 正在运行并将视频发送到流时,播放器上会出现播放按钮,它看起来很正常,但是当没有任何内容流式传输到页面时,它会出现“无法加载媒体,因为服务器或网络出现故障或者因为格式不受支持。”它下面的十字错误。这对我来说不是问题,但该页面将被其他人使用,我不想重复自己该网页没有损坏,只是因为它目前没有流式传输。

有没有办法隐藏错误或更改错误文本以通知流当前未运行。还有一种方法可以让它在流打开时自动播放。这是我当前的文件,它非常基本,只是当时的播放器。

    <!DOCTYPE html>
  2 <html lang="en">
  3 <head>
  4     <meta charset=utf-8 />
  5     <title>Video.js | HTML5 Video Player</title>
  6     <link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">
  7 </head>
  8 <body>
  9
 10   <video-js id="example_video_1" class="vjs-default-skin" controls preload="auto" width="640" height="264">
 11     <source src="http://localhost/live/webcam/index.m3u8" type="application/x-mpegurl">
 12     <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <    a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
 13   </video-js>
 14
 15   <script src="https://unpkg.com/video.js/dist/video.js"></script>
 16   <script src="https://unpkg.com/@videojs/http-streaming/dist/videojs-http-streaming.js"></script>
 17
 18   <script>
 19           var player = videojs('example_video_1', {liveui: true});
 20   </script>
 21 </body>
 22
 23 </html>

最佳答案

根据您想要执行的操作,您可以使用 null 调用 player.error() 来告诉 Video.js 隐藏错误:player.错误(空)。 如果你只想禁用错误,你可以在播放器选项中将 errorDisplay 选项设置为 false:

var player = videojs('vid', {
  errorDisplay: false
});

希望对您有所帮助。

关于nginx - Videojs - 流未运行时隐藏错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59683789/

相关文章:

Nginx:通过 URL 路径提供静态文件

configuration - Nginx 代理或重写取决于用户代理

android - React native/安卓直播播放器

android - 无法在 Ice Cream Sandwich 中播放 HLS 流

javascript - 为什么videojs进度条不固定

nginx - NGINX 配置文件的顺序是什么

php - 仅当 Nginx 文件不存在时才将 URL 重定向到 PHP

streaming - 如何制作直播音频流网站?

jquery - 如何立即暂停所有视频 (html5)?

video.js - VideoJS 4.0 插件 : How to properly add items to the controlBar?