我已经设置了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>
发布于 2020-04-01 06:59:36
根据您想要做的事情,您可以使用null
调用player.error()
来告诉Video.js隐藏错误:player.error(null)
。如果您只想禁用错误,可以在播放器选项中将errorDisplay
选项设置为false
:
var player = videojs('vid', {
errorDisplay: false
});
希望这能有所帮助。
https://stackoverflow.com/questions/59683789
复制相似问题