Permalink
Browse files

Fix audio support.

  • Loading branch information...
1 parent b1d6dc2 commit 6feba217c1d2adb735436e98a22ee6a03a289cbf @jverkoey committed Mar 9, 2010
Showing with 32 additions and 17 deletions.
  1. +13 −0 dev/engine/class.scene.js
  2. +19 −17 dev/engine/class.sound.js
@@ -116,6 +116,8 @@ Breeze.Engine.Scene.prototype.sound = function(key) {
Breeze.Engine.Scene.prototype.drawScene = function() {
this.ctx_.clearRect(0,0,this.ctx_.canvas.width,this.ctx_.canvas.height);
+ this.beforeDrawLayers();
+
for (var i = this.firstLayer_; i <= this.lastLayer_; ++i) {
var oldAlpha = this.ctx_.globalAlpha;
var oldFillStyle = this.ctx_.fillStyle;
@@ -125,6 +127,17 @@ Breeze.Engine.Scene.prototype.drawScene = function() {
this.ctx_.globalAlpha = oldAlpha;
this.ctx_.fillStyle = oldFillStyle;
}
+
+ this.afterDrawLayers();
+};
+
+Breeze.Engine.Scene.prototype.beforeDrawLayers = function() {
+};
+
+Breeze.Engine.Scene.prototype.afterDrawLayers = function() {
+};
+
+Breeze.Engine.Scene.prototype.drawLayer = function(level) {
};
/**
@@ -40,40 +40,42 @@ Breeze.Engine.Sound = function(path, options) {
*/
this.loaded_ = false;
- if (Modernizr.audio) {
- this.audio_ = document.createElement('audio');
+ /**
+ * @type {Object}
+ * @private
+ */
+ this.audio_ = document.createElement('audio');
- if (settings.repeats) {
- this.audio_.addEventListener("ended", function() {
- this.audio_.play();
- }.bind(this), true);
- }
+ if (settings.repeats) {
+ this.audio_.addEventListener("ended", function() {
+ this.audio_['play']();
+ }.bind(this), true);
+ }
- if (this.audio_.canPlayType('audio/mp3')) {
- this.audio_.setAttribute('src', path+'.mp3');
- } else if (this.audio_.canPlayType('audio/ogg')) {
- this.audio_.setAttribute('src', path+'.ogg');
- } else {
- // No supported file formats.
- }
+ if (this.audio_['canPlayType']('audio/mp3')) {
+ this.audio_.setAttribute('src', path+'.mp3');
+ } else if (this.audio_['canPlayType']('audio/ogg')) {
+ this.audio_.setAttribute('src', path+'.ogg');
+ } else {
+ // No supported file formats.
}
};
Breeze.Engine.Sound.prototype.play = function() {
if (this.audio_) {
- //this.audio_.play();
+ this.audio_['play']();
}
};
Breeze.Engine.Sound.prototype.stop = function() {
if (this.audio_) {
- this.audio_.pause();
+ this.audio_['pause']();
}
};
Breeze.Engine.Sound.prototype.setVolume = function(perc) {
if (this.audio_) {
- this.audio_.volume = perc;
+ this.audio_['volume'] = perc;
}
};

0 comments on commit 6feba21

Please sign in to comment.