小编Tyl*_*rch的帖子

Videojs - 流未运行时隐藏错误

我已经设置了 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 …
Run Code Online (Sandbox Code Playgroud)

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

4
推荐指数
1
解决办法
4214
查看次数