x


User choose audio from HardDisk/Cd

How to give the user the ability to choose the audio file(wav,mp3,ogg, etc) from his/her harddisk or CD and play it in a unity game? Note: I mean unity game does not contain that audio file but the user has it on his/her harddisk or CD.

Alternative Question: If this is not possible through programming/scripting nice user interface, is it possible for the user manually (ex, drag his MP3 file and "rename it" and put in a target folder saw unity game can "read" or play it?

more ▼

asked Feb 10 '10 at 07:35 PM

boribhi gravatar image

boribhi
152 6 6 19

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

It sounds like you are looking for a file browser for the user to choose a local file. Have a look at these questions:

Question1 Question2

You can find an example of a browser in the wiki (link) or this link might help (link)

Once the file is selected, you load the file and treat it like a normal audio clip.

more ▼

answered Feb 10 '10 at 08:02 PM

Sebas gravatar image

Sebas
4k 12 18 45

unity can just play ogg files and you should load them with www. to read other file formats like wave you need to convert them to ogg or use a plugin to play them.

Feb 11 '10 at 04:41 AM Ashkan_gc
(comments are locked)
10|3000 characters needed characters left

you can use the WWW class and it's audioclip property to load a file and play it. when you want to download the file if you put "file://path" inside the constructor of the class you can load files from the disk. the file should be in ogg format and you need a command line program or plugin to convert wave/mp3 files to ogg or you should play them using a plugin. in windows you can use windows media player's COM component or mci. i don't know about mac osx. the sample included in the above link shows you how to play audio. you should use a "file::path.ogg" as url string.

more ▼

answered Feb 11 '10 at 04:56 AM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3688
x1029
x56

asked: Feb 10 '10 at 07:35 PM

Seen: 2153 times

Last Updated: Feb 10 '10 at 08:18 PM