Settin up the Music

Started by metalmario991, Sun 18/01/2015 17:53:54

Previous topic - Next topic

metalmario991

I've got a music track I want to play but I can't seem to figure out how to play it without getting errors. How would I fix this?

Crimson Wizard

Please give more information about your problem.
How do you put the music into game? What script commands do you try to make it play? What errors do you get (do you get them during game compilation, or when you run the game)? Just any details please?

metalmario991

I've tried typing in PlayMusic and AudioClip the former which I got from the wiki site but neither seem to work
For audio clip I get Variable '(' is already defined and for playmusic it asks me for interger number but I don't know how to set that up without causing errors.

Vincent

AudioChannel* AudioClip.Play(optional AudioPriority, optional RepeatStyle)

Optionally you can supply a priority and Repeat setting; if you do not supply these, the defaults set for the audio clip in the editor will be used.

This command searches through all the available audio channels to find one that is available for this type of audio. If no spare channels are found, it will try to find one that is playing a clip with a lower or equal priority, and interrupt it to replace it with this new sound.

If all audio channels are busy playing higher priority sounds, then this new audio clip will not be played.

This command returns the AudioChannel instance that the new sound is playing on, or null if it did not play for any reason.

NOTE: AGS can only play one MIDI file at a time.

Example:
Code: ags

aExplosion.Play(); 


Compatibility: Supported by AGS 3.2.0 and later versions.

Crimson Wizard

Quote from: metalmario991 on Thu 22/01/2015 00:20:38
I've tried typing in PlayMusic and AudioClip the former which I got from the wiki site but neither seem to work
For audio clip I get Variable '(' is already defined and for playmusic it asks me for interger number but I don't know how to set that up without causing errors.

Alright. You still haven't answer, how did you put actual music in your game? Did you copy music file somewhere? Did you import it in the project?

PlayMusic and AudioClip are different ways to work with audio in AGS. AudioClip is newer, PlayMusic is old one and considered obsolete.
To use AudioClip you must first import music item into the project tree, and then do "aMusic.Play()" where "aMusic" is a name you gave to your clip.
To use PlayMusic you must manually copy music file into "Music" folder in your game folder and call it "MusicX" where X is an integer number. You then do "PlayMusic(X)" in script where X is same number.

Can you also post a part of your script you are using to make it play?

metalmario991

It's an MP3 I downloaded from spacequest.net. I clicked add audio files and put it in
AudioClip("aSQ5_21__Planetside"); is what I tried.

Crimson Wizard

Quote from: metalmario991 on Thu 22/01/2015 22:17:07
It's an MP3 I downloaded from spacequest.net. I clicked add audio files and put it in
AudioClip("aSQ5_21__Planetside"); is what I tried.

No, that is wrong. Try doing this instead:
Code: ags

aSQ5_21__Planetside.Play();

metalmario991

Yes that worked. Thank you Crimson Wizard. :smiley:

SMF spam blocked by CleanTalk