Skip to content

Commit

Permalink
Add mp3 / ogg file support for smaller audio sprites.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauvis Ledford committed May 30, 2012
1 parent 09e5208 commit b9da69e
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/js/core/mandible.helpers.js
Expand Up @@ -222,13 +222,6 @@
return value ? $('<div/>').html(value).text() : '';
};

// Play random type of sound.
h.playRandomSound = function(type){
var soundAr = ns.data[type + 'Sounds'];
var sound = soundAr[Math.floor(Math.random() * soundAr.length)]
this.playSound('/sounds/' + type + '_' + sound + '.wav');
};

h.playSound = function(file){
var theme = ns.data.user.get('sounds');
var $audioPlayer;
Expand Down Expand Up @@ -262,8 +255,8 @@
// Too bad this shorthand doesn't work on Apple Webkit!
// $audioPlayer.attr('src', '/sounds/' + theme + '/all.wav#t=1.7,4.0');
$audioPlayer[0].volume = 0.2;
if (audioPlayer.seekable){
$audioPlayer[0].currentTime = start;
if (audioPlayer.readyState > 1){
$audioPlayer[0].currentTime = start;
}else{
$audioPlayer.bind('loadeddata', function(){
$audioPlayer[0].currentTime = start;
Expand Down
7 changes: 6 additions & 1 deletion src/js/views/app/app.js
Expand Up @@ -30,9 +30,14 @@
},

setTheme: function(){
var ext = '.mp3';
var theme = ns.data.user.get('sounds');
// Most browsers support mp3 but Firefox, falling back to .ogg.
if ($.browser.mozilla){
ext = '.ogg';
}
if (theme !== 'none'){
$('#audio-player').attr('src', '/sounds/' + theme + '/all.wav');
$('#audio-player').attr('src', '/sounds/' + theme + '/all' + ext);
}
},

Expand Down
Binary file added src/sounds/ki/all.mp3
Binary file not shown.
Binary file added src/sounds/ki/all.ogg
Binary file not shown.
Binary file added src/sounds/random/all.mp3
Binary file not shown.
Binary file added src/sounds/random/all.ogg
Binary file not shown.
Binary file added src/sounds/random/originals/all.wav
Binary file not shown.
Binary file added src/sounds/random/originals/applause.wav
Binary file not shown.
Binary file added src/sounds/random/originals/cheering.wav
Binary file not shown.
Binary file added src/sounds/random/originals/fanfare.wav
Binary file not shown.
Binary file added src/sounds/random/originals/mmmm.wav
Binary file not shown.
Binary file added src/sounds/random/originals/whahwhah.wav
Binary file not shown.
Binary file added src/sounds/random/originals/woow.wav
Binary file not shown.

0 comments on commit b9da69e

Please sign in to comment.