Skip to content

Commit

Permalink
Added a build clip functionality to the AudioPlayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
NTaylorMullen committed Aug 6, 2013
1 parent 1051463 commit fb18a61
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
12 changes: 11 additions & 1 deletion EndGate/EndGate.Core.JS/Sound/AudioPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ var EndGate;
*/
var AudioPlayer = (function () {
function AudioPlayer(source) {
this._source = source;
if (!(source instanceof Array)) {
this._source = [];
this._source.push(source);
} else {
this._source = source;
}
}
AudioPlayer.prototype.BuildClip = function (settings) {
if (typeof settings === "undefined") { settings = Sound.AudioSettings.Default; }
return new Sound.AudioClip(this._source, settings);
};

AudioPlayer.prototype.Play = function (settings) {
if (typeof settings === "undefined") { settings = Sound.AudioSettings.Default; }
var clip = new Sound.AudioClip(this._source, settings);
Expand Down
23 changes: 21 additions & 2 deletions EndGate/EndGate.Core.JS/Sound/AudioPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module EndGate.Sound {
* Defines an AudioPlayer that is mapped to a specific source. Ultimately used to play the same sound simultaneously.
*/
export class AudioPlayer {
private _source: any;
private _source: string[];

/**
* Creates a new instance of the AudioPlayer object.
Expand All @@ -20,7 +20,26 @@ module EndGate.Sound {
*/
constructor(source: string[]);
constructor(source: any) {
this._source = source;
if (!(source instanceof Array)) {
this._source = [];
this._source.push(source);
}
else {
this._source = source;
}
}

/**
* Builds an AudioClip with the default settings.
*/
public BuildClip(): AudioClip;
/**
* Builds an AudioClip with the provided settings.
* @param settings Audio settings to play the AudioClip with.
*/
public BuildClip(settings: AudioSettings): AudioClip;
public BuildClip(settings: AudioSettings = AudioSettings.Default): AudioClip {
return new AudioClip(this._source, settings);
}

/**
Expand Down

0 comments on commit fb18a61

Please sign in to comment.