Permalink
Browse files

Add music encoded to mp3 format.

  • Loading branch information...
1 parent 81fabc9 commit 477adb59169bf9a5ab380252c16ec1adc80d1040 @andreasrosdal andreasrosdal committed Nov 29, 2014
@@ -27,13 +27,13 @@ var autostart = false;
var username = null;
-var music_list = [ "battle-epic.ogg",
- "andrewbeck-ancient.ogg",
- "into_the_shadows.ogg",
- "andrewbeck-stings.ogg",
- "trap_a_space_odyssey_battle_for_the_planet.ogg",
- "elvish-theme.ogg",
- "cullambruce-lockhart-dawning_fanfare.ogg"];
+var music_list = [ "battle-epic",
+ "andrewbeck-ancient",
+ "into_the_shadows",
+ "andrewbeck-stings",
+ "trap_a_space_odyssey_battle_for_the_planet",
+ "elvish-theme",
+ "cullambruce-lockhart-dawning_fanfare"];
var audio = null;
/**************************************************************************
@@ -115,12 +115,21 @@ function civclient_init()
audiojs.events.ready(function() {
var as = audiojs.createAll({
trackEnded: function() {
- audio.load("/music/" + music_list[Math.floor(Math.random() * music_list.length)]);
+ if (!supports_mp3()) {
+ audio.load("/music/" + music_list[Math.floor(Math.random() * music_list.length)] + ".ogg");
+ } else {
+ audio.load("/music/" + music_list[Math.floor(Math.random() * music_list.length)] + ".mp3");
+ }
audio.play();
}
});
- as[0].load("/music/" + music_list[Math.floor(Math.random() * music_list.length)]);
audio = as[0];
+ if (!supports_mp3()) {
+ audio.load("/music/" + music_list[Math.floor(Math.random() * music_list.length)] + ".ogg");
+ } else {
+ audio.load("/music/" + music_list[Math.floor(Math.random() * music_list.length)] + ".mp3");
+ }
+
});
@@ -121,3 +121,11 @@ function to_title_case(str)
function get_random_int(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
+
+/**************************************************************************
+...
+**************************************************************************/
+function supports_mp3() {
+ var a = document.createElement('audio');
+ return !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
+}
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
View
@@ -1 +1,2 @@
cp *.ogg ../freeciv-web/src/main/webapp/music/
+cp *.mp3 ../freeciv-web/src/main/webapp/music/
Binary file not shown.

0 comments on commit 477adb5

Please sign in to comment.