Created
April 15, 2013 09:00
-
-
Save benvium/5386843 to your computer and use it in GitHub Desktop.
Code for the bonus section of AppFurnace Tutorial 7
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
| //======================================================================== | |
| // 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