Permalink
Browse files

Add mp3 / ogg file support for smaller audio sprites.

  • Loading branch information...
krunkosaurus committed May 30, 2012
1 parent 09e5208 commit b9da69ef9a4234ff5a76ab7ec442a7bf6492e717
@@ -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;
@@ -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;
View
@@ -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);
}
},
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit b9da69e

Please sign in to comment.