Playing sound by script

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
446
Reaction score
17
First Language
French
Primarily Uses
Can anyone can explain me why this did't work?


AudioManager.playSe(Cancel1.ogg, 90, 100, 0);


It's alway told me Cancel1 was not defined. Thanks.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
I've moved this thread to Javascript Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
There are 2 possible explanations.  Either:


A:  You're using the wrong file ext.  It may be that you need .m4a, not .ogg.


B:  The extension isn't necessary for the filename.


I'm leaning towards B, but try both and see if either of those work.
 

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
Two things, actually--


1. the extension isn't necessary for the filename


2. the format needs to be as an "object". Basically, it needs these things around it: { }


So:

Code:
AudioManager.playSe({name: "filename", pan: 0, pitch: 100, volume: 100});
 

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
446
Reaction score
17
First Language
French
Primarily Uses
AudioManager.playSe({name: "Cancel1", pan: 90, pitch: 100, volume: 0});  giv objet error


AudioManager.playSe({"Cancel1", 90, 100, 0});    give unexpected token ,


I miss something?
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
I took a closer look at the playSe code in the file, and it only uses the filename as an argument.  Adding the other numbers may be the issue.  Try this:


AudioManager.playSe('Cancel1');
 

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
@shockra No, it takes an object, not a filename.


You see that it references things like se.name, which are variables within an object, so se cannot be simply a filename.


AudioManager.playSe = function(se) {
if (se.name) {
this._seBuffers = this._seBuffers.filter(function(audio) {
return audio.isPlaying();
});
var buffer = this.createBuffer('se', se.name);
this.updateSeParameters(buffer, se);
buffer.play(false);
this._seBuffers.push(buffer);
}
};


@XGuarden I found it-- the problem here is the double quotes. Script commands execute using eval and because of this have problems when there are quotation marks identical to what javascript uses by default (it breaks the eval string) so you need to use single quotes:

Code:
AudioManager.playSe({name: 'filename', pan: 0, pitch: 100, volume: 100});
 

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
446
Reaction score
17
First Language
French
Primarily Uses
Working now. But I realize that player are able to move while the soind playing, any wait to restrict movement?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top