Skip to content

Commit 5f93934

Browse files
committed
Removed deprecated properties on play()
1 parent 084c6be commit 5f93934

3 files changed

Lines changed: 22 additions & 60 deletions

File tree

src/soundjs/AbstractSoundInstance.js

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -314,31 +314,12 @@ this.createjs = this.createjs || {};
314314
* The parameters for this method are deprecated in favor of a single parameter that is an Object or {{#crossLink "PlayPropsConfig"}}{{/crossLink}}.
315315
*
316316
* @method play
317-
* @param {String | Object} [interrupt="none"|options] <b>This parameter will be renamed playProps in the next release.</b><br />
318-
* This parameter can be an instance of {{#crossLink "PlayPropsConfig"}}{{/crossLink}} or an Object that contains any or all optional properties by name,
319-
* including: interrupt, delay, offset, loop, volume, pan, startTime, and duration (see the above code sample).
320-
* <br /><strong>OR</strong><br />
321-
* <b>Deprecated</b> How to interrupt any currently playing instances of audio with the same source,
322-
* if the maximum number of instances of the sound are already playing. Values are defined as <code>INTERRUPT_TYPE</code>
323-
* constants on the Sound class, with the default defined by {{#crossLink "Sound/defaultInterruptBehavior:property"}}{{/crossLink}}.
324-
* @param {Number} [delay=0] <b>Deprecated</b> The amount of time to delay the start of audio playback, in milliseconds.
325-
* @param {Number} [offset=0] <b>Deprecated</b> The offset from the start of the audio to begin playback, in milliseconds.
326-
* @param {Number} [loop=0] <b>Deprecated</b> How many times the audio loops when it reaches the end of playback. The default is 0 (no
327-
* loops), and -1 can be used for infinite playback.
328-
* @param {Number} [volume=1] <b>Deprecated</b> The volume of the sound, between 0 and 1. Note that the master volume is applied
329-
* against the individual volume.
330-
* @param {Number} [pan=0] <b>Deprecated</b> The left-right pan of the sound (if supported), between -1 (left) and 1 (right).
331-
* Note that pan is not supported for HTML Audio.
317+
* @param {Object | PlayPropsConfig} props A PlayPropsConfig instance, or an object that contains the parameters to
318+
* play a sound. See the {{#crossLink "PlayPropsConfig"}}{{/crossLink}} for more info.
332319
* @return {AbstractSoundInstance} A reference to itself, intended for chaining calls.
333320
*/
334-
p.play = function (interrupt, delay, offset, loop, volume, pan) {
335-
var playProps;
336-
if (interrupt instanceof Object || interrupt instanceof createjs.PlayPropsConfig) {
337-
playProps = createjs.PlayPropsConfig.create(interrupt);
338-
} else {
339-
playProps = createjs.PlayPropsConfig.create({interrupt:interrupt, delay:delay, offset:offset, loop:loop, volume:volume, pan:pan});
340-
}
341-
321+
p.play = function (props) {
322+
var playProps = createjs.PlayPropsConfig.create(props);
342323
if (this.playState == createjs.Sound.PLAY_SUCCEEDED) {
343324
this.applyPlayProps(playProps);
344325
if (this._paused) { this._setPaused(false); }

src/soundjs/Sound.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ this.createjs = this.createjs || {};
551551

552552
// Class Private properties
553553
/**
554-
* Determines if the plugins have been registered. If false, the first call to play() will instantiate the default
554+
* Determines if the plugins have been registered. If false, the first call to {{#crossLink "play"}}{{/crossLink}} will instantiate the default
555555
* plugins ({{#crossLink "WebAudioPlugin"}}{{/crossLink}}, followed by {{#crossLink "HTMLAudioPlugin"}}{{/crossLink}}).
556556
* If plugins have been registered, but none are applicable, then sound playback will fail.
557557
* @property _pluginsRegistered
@@ -1214,11 +1214,12 @@ this.createjs = this.createjs || {};
12141214
Static API.
12151215
--------------- */
12161216
/**
1217-
* Play a sound and get a {{#crossLink "AbstractSoundInstance"}}{{/crossLink}} to control. If the sound fails to play, a
1218-
* AbstractSoundInstance will still be returned, and have a playState of {{#crossLink "Sound/PLAY_FAILED:property"}}{{/crossLink}}.
1219-
* Note that even on sounds with failed playback, you may still be able to call AbstractSoundInstance {{#crossLink "AbstractSoundInstance/play"}}{{/crossLink}},
1220-
* since the failure could be due to lack of available channels. If the src does not have a supported extension or
1221-
* if there is no available plugin, a default AbstractSoundInstance will be returned which will not play any audio, but will not generate errors.
1217+
* Play a sound and get a {{#crossLink "AbstractSoundInstance"}}{{/crossLink}} to control. If the sound fails to
1218+
* play, an AbstractSoundInstance will still be returned, and have a playState of {{#crossLink "Sound/PLAY_FAILED:property"}}{{/crossLink}}.
1219+
* Note that even on sounds with failed playback, you may still be able to call the {{#crossLink "AbstractSoundInstance/play"}}{{/crossLink}},
1220+
* method, since the failure could be due to lack of available channels. If the src does not have a supported
1221+
* extension or if there is no available plugin, a default AbstractSoundInstance will still be returned, which will
1222+
* not play any audio, but will not generate errors.
12221223
*
12231224
* <h4>Example</h4>
12241225
*
@@ -1230,40 +1231,19 @@ this.createjs = this.createjs || {};
12301231
* var myInstance = createjs.Sound.play("myID", {interrupt: createjs.Sound.INTERRUPT_ANY, loop:-1});
12311232
* }
12321233
*
1233-
* NOTE to create an audio sprite that has not already been registered, both startTime and duration need to be set.
1234+
* NOTE: To create an audio sprite that has not already been registered, both startTime and duration need to be set.
12341235
* This is only when creating a new audio sprite, not when playing using the id of an already registered audio sprite.
12351236
*
1236-
* <b>Parameters Deprecated</b><br />
1237-
* The parameters for this method are deprecated in favor of a single parameter that is an Object or {{#crossLink "PlayPropsConfig"}}{{/crossLink}}.
1238-
*
12391237
* @method play
12401238
* @param {String} src The src or ID of the audio.
1241-
* @param {String | Object} [interrupt="none"|options] <b>This parameter will be renamed playProps in the next release.</b><br />
1242-
* This parameter can be an instance of {{#crossLink "PlayPropsConfig"}}{{/crossLink}} or an Object that contains any or all optional properties by name,
1243-
* including: interrupt, delay, offset, loop, volume, pan, startTime, and duration (see the above code sample).
1244-
* <br /><strong>OR</strong><br />
1245-
* <b>Deprecated</b> How to interrupt any currently playing instances of audio with the same source,
1246-
* if the maximum number of instances of the sound are already playing. Values are defined as <code>INTERRUPT_TYPE</code>
1247-
* constants on the Sound class, with the default defined by {{#crossLink "Sound/defaultInterruptBehavior:property"}}{{/crossLink}}.
1248-
* @param {Number} [delay=0] <b>Deprecated</b> The amount of time to delay the start of audio playback, in milliseconds.
1249-
* @param {Number} [offset=0] <b>Deprecated</b> The offset from the start of the audio to begin playback, in milliseconds.
1250-
* @param {Number} [loop=0] <b>Deprecated</b> How many times the audio loops when it reaches the end of playback. The default is 0 (no
1251-
* loops), and -1 can be used for infinite playback.
1252-
* @param {Number} [volume=1] <b>Deprecated</b> The volume of the sound, between 0 and 1. Note that the master volume is applied
1253-
* against the individual volume.
1254-
* @param {Number} [pan=0] <b>Deprecated</b> The left-right pan of the sound (if supported), between -1 (left) and 1 (right).
1255-
* @param {Number} [startTime=null] <b>Deprecated</b> To create an audio sprite (with duration), the initial offset to start playback and loop from, in milliseconds.
1256-
* @param {Number} [duration=null] <b>Deprecated</b> To create an audio sprite (with startTime), the amount of time to play the clip for, in milliseconds.
1257-
* @return {AbstractSoundInstance} A {{#crossLink "AbstractSoundInstance"}}{{/crossLink}} that can be controlled after it is created.
1239+
* @param {Object | PlayPropsConfig} props A PlayPropsConfig instance, or an object that contains the parameters to
1240+
* play a sound. See the {{#crossLink "PlayPropsConfig"}}{{/crossLink}} for more info.
1241+
* @return {AbstractSoundInstance} A {{#crossLink "AbstractSoundInstance"}}{{/crossLink}} that can be controlled
1242+
* after it is created.
12581243
* @static
12591244
*/
1260-
s.play = function (src, interrupt, delay, offset, loop, volume, pan, startTime, duration) {
1261-
var playProps;
1262-
if (interrupt instanceof Object || interrupt instanceof createjs.PlayPropsConfig) {
1263-
playProps = createjs.PlayPropsConfig.create(interrupt);
1264-
} else {
1265-
playProps = createjs.PlayPropsConfig.create({interrupt:interrupt, delay:delay, offset:offset, loop:loop, volume:volume, pan:pan, startTime:startTime, duration:duration});
1266-
}
1245+
s.play = function (props) {
1246+
var playProps = createjs.PlayPropsConfig.create(props);
12671247
var instance = s.createInstance(src, playProps.startTime, playProps.duration);
12681248
var ok = s._playInstance(instance, playProps);
12691249
if (!ok) {instance._playFailed();}

src/soundjs/data/PlayPropsConfig.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ this.createjs = this.createjs || {};
5858
*
5959
* <h4>Example</h4>
6060
*
61-
* var ppc = new createjs.PlayPropsConfig().set({interrupt: createjs.Sound.INTERRUPT_ANY, loop: -1, volume: 0.5})
62-
* createjs.Sound.play("mySound", ppc);
63-
* mySoundInstance.play(ppc);
61+
* var props = new createjs.PlayPropsConfig().set({interrupt: createjs.Sound.INTERRUPT_ANY, loop: -1, volume: 0.5})
62+
* createjs.Sound.play("mySound", props);
63+
* // OR
64+
* mySoundInstance.play(props);
6465
*
6566
* @class PlayPropsConfig
6667
* @constructor

0 commit comments

Comments
 (0)