Created
June 12, 2012 04:30
-
-
Save edmore/2914988 to your computer and use it in GitHub Desktop.
Sound playback loop function 1st draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sounds = [["How are you", "hi.mp3"], ["Who is this", "who.mp3"], ["How was school", "how.mp3"], ["What is this","what.mp3"], ["Who is this", "who.mp3"], ["1 + 2", "math.mp3"]], | |
presets = ["Who is this", "What is this"]; | |
function loop(){ | |
setTimeout(function(){ | |
var sound = sounds.splice( 0, 1 ), | |
clearDivContents = function( klasses ){ | |
console.log( klasses ); | |
for( var i=0; i < klasses.length; i+=1 ){ | |
$( klasses[i] ).children().detach(); | |
} | |
}; | |
if( sound.length > 0 ){ | |
$("#container").text( sound[0][0] + "?" ); | |
console.log( "Playing " + sound[0][1] ); | |
if ( sound[0][0] === presets[0] ){ | |
console.log( "Display random image of person" ); | |
$("#person").append( "<img src='images/person/person.jpeg'></img>" ); | |
clearDivContents( ["#object"] ); | |
}else if ( sound[0][0] === presets[1] ){ | |
console.log( "Display random image of object" ); | |
$("#object").append( "<img src='images/object/object.jpeg'></img>" ); | |
clearDivContents( ["#person"] ); | |
}else{ | |
clearDivContents( ["#person", "#object"] ); | |
} | |
document.title = "Sound Loop: " + sound[0][0]; | |
$("#question_item > ul").append( "<li>" + sound[0][0] + "?" + "</li>" ); | |
loop(); | |
}else{ | |
document.title = "Sound Loop: End of Session."; | |
$("#container").text( "End of Session." ); | |
clearDivContents( ["#person", "#object"] ); | |
} | |
}, 5000); | |
} | |
loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment