我正在关注 github:https://github.com/videojs/videojs-contrib-hls#getting-started并关注了该帖子 How to play html5 video play m3U8 on mobile and desktop?用于在 Chrome 中流式传输 m3u8。但我不明白为什么这种情况没有发生。我总是在媒体播放器上收到错误消息无效源。
<!DOCTYPE html>
<html>
<head>
<title>Video</title>
<meta charset="utf-8" />
<style>
body {
background: brown;
color: #CCCCCC;
}
</style>
<script src="video.js"></script>
<script src="videojs.hls.min.js"></script>
<script>
var player = videojs('example-video');
player.play();
</script>
</head>
<body>
<video id=example-video width=960 height=540 class="video-js vjs-default-skin" controls>
<source
src="http://esioslive6-i.akamaihd.net/hls/live/202874/AL_P_ESP1_INTER_ENG/playlist_1000.m3u8"
type="application/x-mpegURL">
</video>
</body>
</html>
这是目录。我已经从这里下载了 videojs-contrib-hls
和 videojs-contrib-hls.min
https://github.com/videojs/videojs-contrib-hls/releases
此外,当我从 Chrome 控制台检查时,我发现了一些错误,我尝试解决但失败了。 错误:
Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///C:/Users/MIC/Desktop/sss/videojs.hls.min.js Failed to load resource: net::ERR_FILE_NOT_FOUND
index.html:16 Uncaught ReferenceError: videojs is not defined
知道我哪里做错了吗?
最佳答案
尝试使用js引用的完整路径:
在你的情况下,将是:
<script src="file:///C:/Users/MIC/Desktop/sss/video.js"></script>
<script src="file:///C:/Users/MIC/Desktop/sss/videojs.hls.min.js"></script>
还要检查Network F12 开发者工具中的 选项卡用于检查 js 文件(资源)是否已加载。
关于javascript - m3u8 中的 htm5 视频 src 无法在 Chrome 中播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37455771/