使用VideoJS播放器播放RTMP流 [英] Playing RTMP stream with VideoJS player
问题描述
我正在尝试使用 VideoJS
播放器播放 RTMP
流,以下是我的代码:
I'm trying to play RTMP
stream with VideoJS
player, below is my code:
<head>
<link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>
<body>
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
<source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
</body>
我看到的错误是这样:
VIDEOJS:错误:(代码:4 MEDIA_ERR_SRC_NOT_SUPPORTED)找不到与此媒体兼容的源.MediaError {代码:4,消息:找不到与此媒体兼容的源."}
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media. MediaError {code: 4, message: "No compatible source was found for this media."}
错误非常明显,但是有许多文档向人们展示了使用 VideoJS
播放 RTMP
流的成功案例:
The error is quite clear, but there are plenty of docs showing people success stories of playing RTMP
streams with VideoJS
:
我肯定知道以下URL确实可以在 VLC
播放器上播放,在 JWPlayer
上也可以播放:
I know for sure that the following URL does play on VLC
player and so does it on JWPlayer
:
rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov
可能是什么问题?
推荐答案
如果您想播放 RTMP
,则必须包含 flash-tech
,可从此处获取:
If you wanna play RTMP
you must include flash-tech
which can be retrieved from here:
https://github.com/videojs/videojs-flash
因此正确的代码将是这样:
Hence correct code would be this:
<head>
<link href="http://vjs.zencdn.net/6.2.0/video-js.css" rel="stylesheet">
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>
<body>
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264" data-setup='{"techorder" : ["flash"]}'>
<source src="rtmp://184.72.239.149/vod/mp4/BigBuckBunny_115k.mov" type="rtmp/mp4">
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<script src="http://vjs.zencdn.net/6.2.0/video.js"></script>
<script src="/videojs-flash.js"></script>
</body>
这篇关于使用VideoJS播放器播放RTMP流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!