mediaelement.js - RTMP support for audio streaming?

风流意气都作罢 提交于 2020-01-01 18:16:10

问题


Is there currently any support for streaming audio via RTMP using either native HTML5 or Flash fallback with MediaElement? I saw what looked like support for Video using the flashStreamer option in the video tag 'data-mejsoptions' attribute.


回答1:


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>


来源:https://stackoverflow.com/questions/15671868/mediaelement-js-rtmp-support-for-audio-streaming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!