Skip to content
Permalink
Browse files

fix (play mp3 using swf)

  • Loading branch information...
alpicola committed Jul 1, 2011
1 parent 0d2140b commit 53589519dc0bf4921339c5d8b38eb59d1b8e6cf4
Showing with 4 additions and 3 deletions.
  1. +3 −2 enchant.js
  2. +1 −1 sound.as
  3. BIN sound.swf
@@ -2568,6 +2568,7 @@ enchant.Sound.load = function(src, type) {
type = '';
}
}
type = type.replace('mp3', 'mpeg');

var sound = Object.create(enchant.Sound.prototype);
enchant.EventTarget.call(sound);
@@ -2590,12 +2591,12 @@ enchant.Sound.load = function(src, type) {
sound.dispatchEvent(new enchant.Event('load'));
}, false);
sound._element = audio;
} else if (type.match(/^audio\/(mpeg|mp3)/)) {
} else if (type == 'audio/mpeg') {
var embed = document.createElement('embed');
var id = 'enchant-audio' + game._soundID++;
embed.width = embed.height = 1;
embed.name = id;
embed.src = 'sound.swf?id=' + '&src=' + src;
embed.src = 'sound.swf?id=' + id + '&src=' + src;
embed.allowscriptaccess = 'always';
embed.style.position = 'absolute';
embed.style.left = '-1px';
@@ -23,7 +23,7 @@ package {
_sound.addEventListener(Event.COMPLETE, function(e:Event):void {
ExternalInterface.call([
'function() {',
'enchant._sound["', id, '"].dispatchEvent(new Event("load"));',
'enchant.Sound["', id, '"].dispatchEvent(new Event("load"));',
'}'
].join(''));

BIN -2 Bytes (100%) sound.swf
Binary file not shown.

0 comments on commit 5358951

Please sign in to comment.
You can’t perform that action at this time.