- Home /
how to open an mp3 file and play it on the next scene?
ok, so i need to open an mp3 file, i tried WWW and searched google, but havn't found the answer. www does not support mp3 on computers, ok, so i make a game kinda like audio surf but diffrent, i got everything working except the song selection. i need to enter a path in a textfield, click a button, and it should load the song into a gameobject with DontDestroyOnLoad (), and play it. Thanks for helping.
Answer by BeHappy · Jul 03, 2012 at 10:06 AM
You can do that easily using Audio Source and Audio listener, Add an audio to an empty game object or existing one, there in the inspector of Audio source you will be asked for a audio source file, just drag and drop the audio.
But to import audio, goto Assets-> Import New Assets and select the file you want, it will get added to your project.
You can have this one as a script reference...
while (true) {
if (controller.isGrounded && controller.velocity.magnitude > 0.3) {
audio.clip = walkSounds[Random.Range(0, walkSounds.length)];
audio.Play();
yield WaitForSeconds(audioStepLength);
} else {
yield;
}
}
And refer this link, it has much more... Audio Clip Answers
Have a look on the script reference for Audio Source, Script Reference
no, i wanted to be able to open a new file even after i turn it into an excecutable file, but it's ok, i found the solution, i use resources.
Your answer

Follow this Question
Related Questions
Loading MP3's into an Audio Array and assigning them to members of a GameObject Array 1 Answer
Record all audio output and save it as mp3 (internal and external audio clips) 1 Answer
Play .mp3 file. 2 Answers
Load MP3 file in code 0 Answers
MP3 to OGG Converter, Plugin, Command Line to be used with Unity 1 Answer