Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top