Skip to content

Instantly share code, notes, and snippets.

@benvium
Created April 15, 2013 09:00
Show Gist options
  • Select an option

  • Save benvium/5386843 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/5386843 to your computer and use it in GitHub Desktop.
Code for the bonus section of AppFurnace Tutorial 7
//========================================================================
// Add this bit in, one line for each audio file
//========================================================================
var nameToAudio = {
"audio/story1.mp3":"What I had for breakfast",
"audio/story2.mp3":"What'll have for dinner"
};
// This function returns the track description if there is one, otherwise returns the name of the audio file.
function nameFromAudio(audio) {
if (nameToAudio[audio]) {
return nameToAudio[audio];
}
return audio;
}
//========================================================================
// Called when the story channel updates.
// If it's playing a story, show the name on screen
// and change the size of the 'progress' bar to show how much has been played.
function updateUI(url, elapsed, amount, paused) {
if (url) {
ui.title.text( nameFromAudio(url) ); // <-- CHANGE THIS LINE
ui.progress.width( amount*280 );
ui.progress.hidden(false);
} else {
ui.progress.hidden(true);
ui.title.text("(nothing playing)");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment