Audio URL

Discussion and feedback on Construct 2

Post » Thu Mar 07, 2013 12:59 pm

Hi,
   Is it possible to play an audio file by passing in URL to the audio file, I could not find this option in the Audio Plugin.

-Thanks
mchulet2013-03-07 13:51:22
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Thu Mar 07, 2013 2:51 pm

The main reason this isn't supported is because you need to dual-encode all your audio to two formats for it to play on all platforms. So if you play http://example.com/audio.ogg, it won't work on Microsoft or Apple platforms, and if you play http://example.com/audio.m4a, it won't play on some Firefox or other open-source platforms. The best thing to do is import the audio file to your project so Construct 2 dual-encodes it and then play it from there.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Mar 07, 2013 7:04 pm

In this project I don't have the option of embedding all sound files within the project. There are quite a few of them and not all of them would be required in any single run.
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Thu Mar 07, 2013 7:51 pm

According to the audio manual entry:

[quote]Audio is downloaded on demand

To speed up the loading time and start the game sooner, audio is downloaded or streamed on-demand during the game. In other words, nothing is downloaded until a Play action starts playing an audio file. Then, if the audio file is in the Music folder it starts streaming from the server; if in the Sounds folder, it starts downloading and will play when finished downloading.[/quote]

Looks like you already have exactly what you need ?
Make sure to preload all required sounds (like menu fx for example) on the start of your game, and possibly you could get over with "Play" at any needed time.

This will be dependent on the bandwidth of your users though.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Mar 08, 2013 2:17 pm

No Kyatric, that works only for sound files that are part of the project. It does not work for referring to sound files at runtime.

-Thanks
B
10
S
3
Posts: 69
Reputation: 1,590

Post » Wed Apr 24, 2013 9:34 am

For what it's worth... it works swell for me. And as Kyatric says, it works... but you don't really need a URL per se.

Just upload all your sound files to the media folder. This folder must reside as a subfolder in your project. So even if you have not imported any sound or music into your project, you can always create it on your server. As to the sound files you put inside - it's best you convert them to both ogg and m4a format.

As for coding, just use the "Play (by name)" action and key in the filename without extension.

Voil!necromaster2013-04-24 09:46:43
=========================================
If you are on Linkedin, join other C2 professionals and network on the Scirra Construct 2 Developer Group at https://www.linkedin.com/groups?home=&gid=6732005
B
47
S
10
G
6
Posts: 193
Reputation: 7,604

Post » Tue Jan 06, 2015 10:24 pm

necromaster wrote:For what it's worth... it works swell for me. And as Kyatric says, it works... but you don't really need a URL per se.

Just upload all your sound files to the media folder. This folder must reside as a subfolder in your project. So even if you have not imported any sound or music into your project, you can always create it on your server. As to the sound files you put inside - it's best you convert them to both ogg and m4a format.

As for coding, just use the "Play (by name)" action and key in the filename without extension.

Voil�!necromaster2013-04-24 09:46:43


Is this actually tested and functional? I'll have to try it myself.
ImageImage
B
31
S
9
Posts: 212
Reputation: 4,065

Post » Wed Jan 07, 2015 2:57 pm

It worked for me back then. I should assume it still works with the current version. Try it out and share with us your findings.
=========================================
If you are on Linkedin, join other C2 professionals and network on the Scirra Construct 2 Developer Group at https://www.linkedin.com/groups?home=&gid=6732005
B
47
S
10
G
6
Posts: 193
Reputation: 7,604

Post » Thu Jul 23, 2015 4:35 pm

This works for audio files that are stored in the media folder. What about sound files that are stored in another server? Similar to @mchulet, i am working currently in a project with thousands of audio files.

How would i request the URL of the audio files on another server, would it be through an AJAX get request?
B
82
S
11
G
8
Posts: 153
Reputation: 10,215

Post » Tue Aug 02, 2016 6:58 pm

Everybody says this is not supported because of the 2 file types. That is a no brainier.

But Since we are compiling 2 versions of code for different platforms we know how to set audio for that which we are working on.

Now to the question at hand. How to call an audio file from a web server.
B
29
S
13
G
10
Posts: 355
Reputation: 8,297

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 16 guests