我正在尝试使用rtmp流。我建议的代码几乎相同here
<html>
<head>
<script src="me/build/jquery.js"></script>
<script src="me/build/mediaelement-and-player.js"></script>
<link rel="stylesheet" href="me/build/mediaelementplayer.min.css" /></code>
</head>
<body>
<video>
<source src="000109f6004b00a6004af03676235daa" type="video/rtmp">
</video>
<script>
$('video').mediaelementplayer({flashStreamer:"rtmp://thinkbuntu:1935/flvplayback/000109f6004b00a6004af03676235daa"});
</script>
</body>
</html>
而rtmp://thinkbuntu:1935/flvplayback
是本地rtmpserver的URL,而'000109f6004b00a6004af03676235daa'是mp4视频。我知道本地服务器正在工作,因为我可以通过rtmpdump转储它,还可以使用jwplayer正确播放视频。使用flv进行中介时,webm和ogv都不起作用。
我在Firefox中收到此错误(Chrome中完全没有错误):
Specified "type" attribute of "video/rtmp" is not supported. Load of media resource 000109f6004b00a6004af03676235daa failed.
通过json属性配置它以相同的方式失败。
我也尝试过这种方法Replacing media source (http with rtmp) in MediaElementsJS based on browser capabilities,但也失败了。
我做错什么了吗?
我的设置几乎相同,我的工作正常。不知道是否需要任何属性,但是我在video标签上有一些属性。
(仅供参考,我想多余的</code>
标签只是您粘贴到SO中的?]
<video width="300" height="240" controls="controls" preload="none" id="stream">
<source src="7901e75800f700d700437a45351f0214" type="video/rtmp">
</video>
<script type="text/javascript">
$('#stream').mediaelementplayer({
flashStreamer: "rtmp://170.93.143.150/rtplive/000109f6004b00a6004af03676235daa",
plugins: ['flash', 'silverlight'],
alwaysShowControls: false,
success: function (mediaElement, domObject) {
if (mediaElement.pluginType == 'flash') {
mediaElement.play();
}
},
});
</script>
在您的情况下,您必须在视频标签内添加前缀“ mp4:”
<video width="360" height="203" id="player1" src="mp4:sample" type="video/rtmp" controls="controls"></video>
<script>$('video').mediaelementplayer({flashStreamer:"rtmp://localhost/vod"});</script>
我们必须移植嗅探RTMP流量,以准确确定浏览器正在协商的内容,因为RTMP URL是唯一解释的:URL的一部分标识了流服务端点,其余的标识了流资源,两者之间是文件格式,后跟冒号。如果您不知道RTMP服务器的配置,则无法确定服务端点在URL中的何处结束以及流开始。由于我们不知道服务器的配置,这使我们无比沮丧。
在源代码中,我们将完整的RTMP URL设置为'src'属性(协议,服务端点,流和文件格式-一切,整个shebang),在flashStreamer属性中,我们确定了服务端-仅指向(所有但不包括文件格式的内容)。经过大量的实验,这是属性的唯一成功组合。
请确保您的Firefox已安装Flash。查看Firefox插件中是否有Shockwave flash。如果没有,