Longtime blogger and longtime pal MAS mentioned me over in Make and Host Your Own Soundboard yesterday. I am glad to have contributed to more software. I dig being able to give to code that people use, even if it’s for no money. I love even more that the whole thing is up on GitHub.
It is still astonishing to me that I can read and make improvements to code. Code that at first glance is as peculiar as this:
var ar = <?php echo json_encode($mp3) ?>; var BASE_AUDIO_PATH = '' + <?php echo json_encode($mp3directory) ?> + '/'; // sort files to be in alphabetical order by title ar.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }); // Add <audio> files and buttons to soundboard // preload set to "none" is optional ar.map(function(url){ $('#soundboard').append(function(){ var thisAudio = $('<audio/>').attr({ src: BASE_AUDIO_PATH + url, preload: "none", onplay:"$(this).siblings('button').css('color', 'yellow');", onended: "$(this).siblings('button').css('color', 'white');" }) var buttonText = url.replace(/-/g, ' ').replace('.mp3', '').replace('[Q]','?'); var thisButton = $('<button />').addClass('myButton').text(buttonText); return $('<span />').addClass('track').append(thisAudio).append(thisButton); }) }); $('#soundboard').on( 'click', 'button', function() { $(this).siblings('audio').get(0).play(); });
And not be driven insane looking at it.
Programming is fun!