Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing audio stream using html5

How can i play RTSP streams with HTML5 audio tag, I already check streaming links from wowza http and RTSP both work perfectly on VLC but when I embed these links in html5 audio tag, nothing seems to work any help would be appreciated. Here is my HTML5 code

<!DOCTYPE html>
<html>
    <body>
        <audio controls>
            <source src="http://[ServerIP]:1935/bw/_definst_/mp3:audio/64kbps/A_B_C_D_Any_Body_Can_Dance_Bezubaan.mp3/playlist.m3u8" type="audio/mpeg">
            Audio not supported 
        </audio>
    </body>
</html>

Edit: Stream works on smartphones perfectly, but doesn't work on PC browsers

like image 692
KKK Avatar asked Mar 10 '14 09:03

KKK


1 Answers

HLS (m3u8 files) will play on iOS (and some Android but support can be clunky) and Mac OS Safari in an HTML5 audio tag: <video width="640" height="360" preload="auto" controls src="http://[ServerIP]:1935/vod/test.mp4/playlist.m3u8"></video>

RTSP can be played on Android via an a tag in Chrome:

<div id="myElement">
<a href="rtsp://[ServerIP]:1935/vod/mp4:test.mp4">watch this stream over RTSP</a>
</div> 

RTSP should work in a HTML5 video tag on Android but only on the native browser (well that is my experience of it I normally use the a tag as Chrome is now the default browser in Android 4+): <video width="640" height="360" preload="auto" controls src="rtsp://[ServerIP]:1935/vod/sample.mp4"> </video>

To support desktop PC, either provide a download link to the video tag src (mp3, ogg, wav ..) or if you have to use a streaming protocol you will need to resort to a plugin like Flash (and feed it a RTMP or HDS feed).

There is the VLC plugin for web browsers that can allow playback of RTSP streams but that is in an embed tag: <embed TYPE="application/x-vlc-plugin" autoplay="no" loop="no" width="640" height="360" target="rtsp://[ServerIP]:1935/vod/sample.mp4"></embed>

Though HTML5 video is protocol agnostic it is dependent on the web browser/OS manufacturer implementation and that can vary along time and manufacturers.

like image 144
Arnaud Leyder Avatar answered Oct 02 '22 00:10

Arnaud Leyder