mediaelement.js - RTMP support for audio streaming?

…衆ロ難τιáo~ 提交于 2019-12-04 17:23:10

I know your question is a year old but I'm going to try and answer it in the hope I can save someone the time and trouble of figuring it out.

As far as I'm aware RTMP is not supported in any of the native HTML5 audio/video elements.

Luckily mediaelement.js seems to support this protocol in here Flash version

It seems this protocol is used more commonly for videos. That is why you'll have to provide a few extra arguments to make a RTMP stream work.

Here is how I got a RTMP audio stream working with mediaelement.js:

JavaScript:

$('video,audio').mediaelementplayer({
    audioWidth: 500,
    features: ['playpause','current', 'progress', 'volume'],
    pluginVars: 'isvideo=true',
    //Example rtmp://my-streaming-service.com/specific-stream
    flashStreamer: "rtmp://<base-url+path>",
    mode:'shim'
});

HTML:

<audio preload="none" controls="controls">
    <!-- Example rtmp://my-streaming-service.com/specific-stream/64.stream -->
    <source src="rtmp://<base-url+path>/<filename>" type="video/mp4"> 
</audio>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!