Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox?

Jose Nobile

The current version of Mozilla Firefox is 23.0.1, this version does not support play MP3 shoutcast streams from a TCP port different to 80 (most common is 8000 for Shoutcast 1.9.8).

I use Flash when MP3 support is not available in HTML5 audio, the way to detect is:

try{
    var a = document.createElement('audio');
    r = !!(a.canPlayType && !!a.canPlayType("audio/mpeg; codecs=mp3").replace(/^no$/,''))
}catch(e){
    r = false;
}

The support for Mp3 shoutcast streams in Firefox will be added in version 24.

a.canPlayType("audio/mpeg; codecs=mp3") = probably in Chrome and Firefox, Chrome really support, firefox does not support, due to this the current code to detect not work for Firefox.

The current version of jQuery that support IE 6 is 1.10.2, this version does not has .browser

I think the "stylized" way is testing features and not querying for browsers / versions, notwithstanding here I see hard not to violate this "principle".

What is the "stylized" way of detect MP3 ICY support without navigator.userAgent in Firefox?

Jose Nobile

There is no sophisticated way to detect it. The good news is the last stable Firefox 24.0 support play shoutcast streams in MP3 with HTML5 audio. The best way to detect the support that I wrote:

function icy(){
    try{
        if(!navigator.userAgent.match(/Trident\/7\./) && $.browser.mozilla && $.browser.version < 24)
            return false;//https://bugzilla.mozilla.org/show_bug.cgi?id=869725
        var a = document.createElement('audio');
        r = !!(a.canPlayType && !!a.canPlayType("audio/mpeg; codecs=mp3").replace(/^no$/,''))
    }catch(e){
        r = false;
    }
    return r;
}

If you use the lastest jQuery 1.10.2, you need include jQuery Migrate plugin to use $.browser

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Javascript navigator.userAgent always show the same agent in Firefox

Why does window.navigator.userAgent show wrong Firefox version?

Detect Firefox support for screen sharing

Firefox supports mp3

How to detect async function support without eval?

MP3 Audio Support in Browsers

MP3 player with good podcast support?

SoundJS: Firefox is not able to play a mp3

Firefox native support for userscripts - without addons

Identify the window.navigator.userAgent from a backgroundscript

getting a Firefox plugin to detect and mimic attempts to check for Apple Pay support

Play SHOUTcast DNAS without entering admin panel

Software to detect mp3 almost-duplicates?

Decode MP3 into PCM using JLayer to detect amplitude

ffmpeg detect when a mp3 remote audio changes

how to set the support of mp3 and ffmpeg codec libraries to cef?

Detecting MP3 support in a page for old browser

Download .mp3 file instead of playing them in firefox or chrome?

html5 audio mp3 not working in firefox

I can't play MP3 files directly on Firefox

SoundJS: Why can't FireFox play mp3 file?

Firefox launches Anaconda Navigator

How can I reliably detect the browser without using window.navigator?

Cordova - Deprecated attempt to access property 'userAgent' on a non-Navigator object

If window.navigator.userAgent is deprecated, what should I use instead?

Simulator hangs con execute browserComponent.executeAndReturnString("navigator.userAgent"

navigator.userAgent different for each browser, what is the meaning of values in it?

Mismatch in UserAgent initiating Firefox manually and using GeckoDriver

How to convert flv to mp3 on ubuntu 14 without ffmpeg

TOP Ranking

HotTag

Archive