Is it possible to play shoutcast internet radio streams with html5?

前端 未结 10 2161
自闭症患者
自闭症患者 2020-12-02 09:15

Is it possible to play shoutcast (or some) internet radio streams with html5?

So I have next code:



相关标签:
10条回答
  • 2020-12-02 09:54

    The above posts give the correct answer, allthough they don't mention the use of the slash. Make sure /; is there after the stream URL and port.

    <audio src="http://shoutcast.internet-radio.org.uk:10272/;" />
    
    0 讨论(0)
  • 2020-12-02 09:56

    reading the HTML 5 audio specification (http://www.w3schools.com/html5/html5_audio.asp) W3C outlines which formats (MP3 or OGG) are supported by which browsers

    What i would do is have an icecast server (not ShoutCast) streaming a MP3 and an OGG stream

    using javascript detect the browser type - http://www.javascripter.net/faq/browsern.htm

    if (the browser does not support HTML5){ print a message - USE a New Browser }

    if (the browser supports HTML5 and OGG streaming (use list from W3c)){ use the OGG stream from the icecast server in the SRC tag }

    if (the browser supports HTML5 MP3 streaming (use list from W3C)){ use the MP3 stream from the icecast server in the SRC tag }

    i think this would cover all the major browsers and would solve most peoples problems you will probably find in the future this will be redundant as more browsers support

    0 讨论(0)
  • 2020-12-02 10:03
    <audio controls src="http://example.com:8000/mountpath;"></audio>
    
    0 讨论(0)
  • 2020-12-02 10:04

    Well, Firefox and Opera do not support non-Free codecs such as mp3 (as with the Opera 10.5 alpha, FF 3.5 and later supports only PCM wav and Ogg Vorbis for audio). I believe Chrome and Safari do support MP3, however.

    The next problem is that your URL appears to point to a webpage describing the stream, not to a stream.

    Finally, as far as I know, no one has implemented a playlist parser for the audio element (the spec only mentions audio files, not playlists), which is a problem here, as even when you click "listen" you get a playlist rather than a raw stream.

    0 讨论(0)
  • 2020-12-02 10:06

    Add a semicolon to the end of the http request. It IS the protocol set forth by shoutcast to override its browser detection. Like this example:

    <audio controls src="http://shoutcast.internet-radio.org.uk:10272/;"></audio>
    
    0 讨论(0)
  • 2020-12-02 10:07

    Yes you can play ShoutCast2 I use it like this in this way

    <audio preload="none" autoplay="autoplay" controls="controls">
        <source src="http://178.32.62.172:9079/stream" type="audio/mpeg">
        Your browser does not support this player, please update the version
    </audio>
    
    0 讨论(0)
提交回复
热议问题