gpt4 book ai didi

javascript - 播放 video.js ustream m3u8 文件流

转载 作者:太空狗 更新时间:2023-10-29 14:03:14 27 4
gpt4 key购买 nike

我试过用video.js在网页中播放一个m3u8文件流,但是我做不到,我不知道错误在哪里

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Video</title>

<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<script src="https://github.com/videojs/videojs-contrib-media-sources/releases/download/v0.1.0/videojs-media-sources.js"></script>
<script src="https://github.com/videojs/videojs-contrib-hls/releases/download/v0.11.2/videojs.hls.min.js"></script>

</head>
<body>
<h1>Video</h1>

<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
data-setup='{}'>
<source src="http://iphone-streaming.ustream.tv/uhls/3064708/streams/live/iphone/playlist.m3u8" type='video/mp4'>
</video>

<script>
</script>

</body>
</html>

最佳答案

您需要 type='application/x-mpegURL' 而不是 type='video/mp4'

还要检查是否允许跨域请求 (CORS)。

Hosting Considerations

Unlike a native HLS implementation, the HLS tech has to comply with the browser's security policies. That means that all the files that make up the stream must be served from the same domain as the page hosting the video player or from a server that has appropriate CORS headers configured. Easy instructions are available for popular webservers and most CDNs should have no trouble turning CORS on for your account.

来源:https://github.com/videojs/videojs-contrib-hls

CORS 操作指南:http://enable-cors.org/server.html

关于javascript - 播放 video.js ustream m3u8 文件流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29351225/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com