Music

For questions about using Classic.

Post » Thu Oct 16, 2008 6:06 pm

Im new user of construct and can get musics working. I tried with wav/mp3 with Xaudio2.
Example if I got music file called "Backround.mp3" how I should get it working :?
B
27
S
3
G
5
Posts: 172
Reputation: 3,628

Post » Thu Oct 16, 2008 6:55 pm

Can XAudio play mp3s? I had some impression that there are licensing restrictions forcing us to use mainly .ogg?

*waits for someone who knows :)
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Thu Oct 16, 2008 7:01 pm

pretty sure i've played an .mp3 file easily with xaudio2

as far as the OP goes, make sure to include the path of the file (not just the name).
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Thu Oct 16, 2008 7:06 pm

But theres one little problem, if I do it like "C:\Documents & Setting\user\Name\Game\Music\Music.mp3" it will only work with me but if someone else tries it wont play them.
B
27
S
3
G
5
Posts: 172
Reputation: 3,628

Post » Thu Oct 16, 2008 7:10 pm

[quote="l33twash0r":v7tgm7n7]But theres one little problem, if I do it like "C:\Documents & Setting\user\Name\Game\Music\Music.mp3" it will only work with me but if someone else tries it wont play them.[/quote:v7tgm7n7]
put the sound file in the same folder as the .cap or .exe and use

[code:v7tgm7n7]AppPath + "music.mp3"[/code:v7tgm7n7]
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Thu Oct 16, 2008 7:11 pm

Or do AppPath +/Music/Music.mp3"
But Path object is bugged soooo its best to Binary that music.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Oct 16, 2008 7:59 pm

Umm how I can binary music then?
B
27
S
3
G
5
Posts: 172
Reputation: 3,628

Post » Thu Oct 16, 2008 8:35 pm

[quote="l33twash0r":11j7sxtn]Umm how I can binary music then?[/quote:11j7sxtn]

In your resources tab, right click on "Binary" and select "Add file" to add a copy of the file to the .exe itself. You can now use "Play music from resorce or "Play file from resource" or whatever in the events.

[quote="dfyb":11j7sxtn]put the sound file in the same folder as the .cap or .exe and use

[code:11j7sxtn]AppPath + "music.mp3"[/code:11j7sxtn][/quote:11j7sxtn]

If it's in the same folder you just have to put "\music.mp3"

If it's in a subfolder of the same folder just do "\sub\music.mp3"

Relative paths work fine like that.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 16, 2008 8:49 pm

Ok thanks this will help me alot.
B
27
S
3
G
5
Posts: 172
Reputation: 3,628

Post » Thu Oct 16, 2008 10:53 pm

AppPath returns a backslash at the end. And you should use backslashes (\) not forward slashes (/) for local files. So the correct formatting for a subfolder would be:

AppPath + "Music\File.mp3"
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests