1. Check out our companion app, Forums for Android! Download from Google Play

Android 4.0.3 Browser - audio.canPlayType() not working ?

Discussion in 'Application Development' started by rickygai, Aug 1, 2012.

  1. rickygai

    rickygai New Member
    Thread Starter
    5

    Aug 1, 2012
    1
    0
    5
    I am using Samsung Galaxy S2, Andriod 4.0.3 and below is HTML5 audio elements JavaScript to detect if Android default Browser support certain audio types of MP3, OGG and WAV.

    function OnAudioSupportGet (audio)
    {
    var ext = "";
    if( audio.canPlayType("audio/ogg") =="probably" ||
    audio.canPlayType("audio/ogg") == "maybe")
    {
    ext = "ogg";
    }
    else
    if( audio.canPlayType("audio/wav") =="probably" ||
    audio.canPlayType("audio/wav") == "maybe")
    {
    ext = "wav";
    }
    else
    if( audio.canPlayType("audio/mp3") == "probably" ||
    audio.canPlayType("audio/mp3") == "maybe")
    {
    ext = "mp3";
    }

    return ext;
    }

    Via html5test.com, it seems default Android Browser able to play MP3 but
    yet, it failed to be recognized at instructions above.

    Any help, link, hint or guideline will be appreciated :eek:)
     

    Advertisement

Share This Page

Loading...