I am creating a car game. Is any way to play the music stored on the phone inside the game? I'd like the player to choose files that are already on their device and hear them played in the game.

For example, in GTA Vice City game there was a folder named Music, and if we placed songs in there they would play on the car radio while we're driving around inside the game. If we want to switch the songs around, we can do so. how can I do the same in Android and iOS?

I am using unity 5.2, C#.


1 Answer 1


It is possible to do so. Given a directory, unity's WWW class will be able to obtain the file using the URL. You can then create a clip with that file and pass it to the audio source.

Do note that you will have to either hard code a directory on the phone, use a navigator to allow the user to select the folder or create a searcher to find all audio files.

Use file://<filepath> to access a local resource. Do take note that different devices have different file structure and you have to adapt for each of them.

  • \$\begingroup\$ www class is used to access webpage. using this method is it possible to play the MP3 stored in local sd card? Note : it must play only the songs stored in local SD card. i dont want to buffer the song from online \$\endgroup\$ Commented Mar 3, 2016 at 4:01
  • 2
    \$\begingroup\$ WWW is used to access a resource via its URL. URL stands for Uniform Resource Link and its not limited to online resources. Using the file://<dir> URL, you can access a local file. \$\endgroup\$
    – DarkDestry
    Commented Mar 3, 2016 at 4:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .