Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: metalmario991 on Sun 18/01/2015 17:53:54

Title: Settin up the Music
Post by: metalmario991 on Sun 18/01/2015 17:53:54
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?
Title: Re: Settin up the Music
Post by: Crimson Wizard on Sun 18/01/2015 18:22:30
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?
Title: Re: Settin up the Music
Post by: 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.
Title: Re: Settin up the Music
Post by: Vincent on Thu 22/01/2015 02:20:54
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) Select

aExplosion.Play();


Compatibility: Supported by AGS 3.2.0 and later versions.
Title: Re: Settin up the Music
Post by: Crimson Wizard on Thu 22/01/2015 08:48:08
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?
Title: Re: Settin up the Music Crimson Wizard
Post by: 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.
Title: Re: Settin up the Music
Post by: Crimson Wizard on Thu 22/01/2015 22:46:17
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) Select

aSQ5_21__Planetside.Play();
Title: Re: Settin up the Music
Post by: metalmario991 on Fri 23/01/2015 00:01:39
Yes that worked. Thank you Crimson Wizard. :smiley: