Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by edwin861986 · Feb 27, 2013 at 06:35 PM · audiosourceaudioclipogg

Loading OGG file, work in unity-editor, not outside

Hey,

im basicly loading 10 ogg files from a certain folder. That all works fine, playing them too. But when i pulbish my build and try it from there, the songs cant load. Doesnt even give errors and it does find the songs. Im really clueless.

 try
 {
     string path = Application.dataPath;
     path = path.Substring(0,path.LastIndexOf("/")) + "/Music";
     allMusicClips = new ArrayList();
     DirectoryInfo info = new DirectoryInfo(path);
     fileInfo = info.GetFiles();
     for (int i=0;i<fileInfo.Length;i++)
     {
          WWW www = new WWW("file://"+fileInfo[i].ToString());
                       StartCoroutine(FinishedLoadingSong(www));
             }
         }
         catch (System.Exception e)
         {
             Debug.Log(e.ToString());
         }
 
 
 
 IEnumerator FinishedLoadingSong(WWW www)
     {
         yield return www;
         AudioClip temp =www.GetAudioClip(true,true);
         temp.name = www.url;
         allMusicClips.Add(temp);
         AbleToPlayMP3 = true;
     }
 

Edit: code format is good now, sorry about that

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GerryM · Feb 27, 2013 at 10:13 PM 0
Share

Your script seems cut off, please, paste the whole script, and use the code sample format (the button with the 101 010) to make it readable.

avatar image Graham-Dunnett ♦♦ · Feb 27, 2013 at 10:59 PM 0
Share

What's your build target? The webplayer (and the mac and linux standalones, and the Android and iOS targets) have no access to a `G:` drive.

avatar image edwin861986 · Feb 28, 2013 at 02:14 AM 0
Share

Build target is windows

avatar image liamcary · Feb 28, 2013 at 05:49 AM 0
Share

Have you copied the songs over to the data folder in the build? Application.dataPath in your unity project is not the same as Application.dataPath for your build. And I believe the songs would only copy with the project if you put them in the Resources folder.

avatar image edwin861986 · Feb 28, 2013 at 03:00 PM 0
Share

Yes i have, my build is finding the songs np

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Tarlius · Feb 28, 2013 at 06:57 AM

Since you seem to be using built in types (AudioClip), you will probably save yourself a lot of headaches if you do it "the unity way" and just put your songs in a Resource folder and use Resources.Load to load your assets.

Things will get more complicated if you need to add downloadable content/etc, but theres ways to get unity to do that for you too (AssetBundles)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image edwin861986 · Feb 28, 2013 at 03:01 PM 0
Share

I know, with resources it'd have been fixed easily. But i want the possibility to just put songs in a folder without needing to rebuild etc... It's odd that it's this complicated...

avatar image Tarlius · Feb 28, 2013 at 11:29 PM 1
Share

As long as you are aware the option exists. It can make life much easier. You can add after release with asset bundles, by the way.

avatar image edwin861986 · Mar 01, 2013 at 06:09 AM 0
Share

yea i didnt know it existed tbh, thanks a lot :)

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Audio Track from Ogg Video File Doesn't Play 0 Answers

Multiple audiosources 1 Answer

Play AudioSource Backwards 2 Answers

AudioClip.Create crash on Mac OSX 1 Answer

What are the advantages of stereo sound effects? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges