www.webdeveloper.com
Results 1 to 3 of 3

Thread: firefox issues with audio tag

  1. #1
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    81

    firefox issues with audio tag

    so in firefox the audio in the tag generated by section 1 of this script displays for a few seconds and then disappears. the part in section 2, however, works just fine... I've given up on IE9 (anyone know how to even get HTML5 audio to even show up in IE9?) but all parts of this code work just fine in Chrome and Safari.. help?

    section 1:
    function int_quiz(){
    while(int_loop<21){
    var intervalfile=choose_interval();
    document.getElementById('sound'+int_loop).innerHTML = "\
    <div id='audio"+int_loop+"'>\
    <audio controls id='1' onended='intplaycounter(this)'>\
    <source src='sounds/intervals/"+intervalfile+".ogg' id='intfile"+int_loop+"' type='audio/ogg'>\
    <source src='sounds/intervals/"+intervalfile+".mp3' type='audio/mpeg'>\
    <source src='sounds/intervals/"+intervalfile+".wav' type='audio/wav'>\
    Your browser does not support the audio element.\
    </audio></div>\
    <input type='text' id='user_input"+int_loop+"' value='Type answer here'\
    onfocus='clearThis(this)'/>\
    <button onclick='int_check_ans("+int_loop+")'>Check Answer</button>\
    </form>";
    int_loop++;
    }
    }

    section 2:
    function chd_quiz(chdtyp){
    while (chd_count < 21){
    var chd_folder=choose_folder(chdtyp),
    chord=choose_chord();
    document.getElementById('sound'+chd_count).innerHTML = "\
    <div id='audio"+chd_count+"'>\
    <audio controls id='1' onended='chdplaycounter(this)'>\
    <source src='sounds/chords/"+chdtyp+"/"+chd_folder+"/"+chord+".ogg' id='chdfile"+chd_count+"' type='audio/ogg'>\
    <source src='sounds/chords/"+chdtyp+"/"+chd_folder+"/"+chord+".mp3' type='audio/mpeg'>\
    <source src='sounds/chords/"+chdtyp+"/"+chd_folder+"/"+chord+".wav' type='audio/wav'>\
    Your browser does not support the audio element.\
    </audio></div>\
    <input type='text' id='user_input"+chd_count+"' value='Type answer here'\
    onfocus='clearThis(this)'/>\
    <button onclick='chd_check_ans("+chd_count+")'>Check Answer</button>\
    </form>";
    chd_count++;
    }
    }

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    why does the ogg source have an ID an nothing else does? since FF uses ogg, i would start my investigation there. You don't post enough code to determine the actual problem.

  3. #3
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    81
    well i did try moving the id on the ogg source to a different source and it didn't make a difference, but the only reason I have only source tag with an id is because the part of the script below uses that id to perform it's function... and if i'm not mistaken, if i were to assign the same id to multiple elements it would likely throw an error right?

    Code:
    function find_int_ans(num){
        var correct,
            init_string=document.getElementById('intfile'+num).getAttribute('src'),
            path_split=init_string.split("/"),
            result=path_split[2];
            /// series of if/else statements ///
        return correct;
    }
    
    function int_check_ans(num){
        var correct_ans = find_int_ans(num),
            user_ans=document.getElementById('user_input'+num).value;        
    other code
    }
    Last edited by thewebiphyer; 03-14-2013 at 01:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles