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 VivekD · Apr 03, 2013 at 12:42 PM · audiowwwaudioclipyield

Issues with WWW resource loading

I am using the WWW class to load audio-clips at runtime as selected by the user. However, I am currently facing two issues. I am posting a code example here to explain.

     IEnumerator LoadSong(string trackpath)
     {        
         WWW checker = new WWW("file://"+trackpath);
 
         yield return checker;
         
         audClip = checker.GetAudioClip(true,true);
         
     }

This NEVER works. More specifically the line yield return checker; doesn't. I have to replace that with while(!checker.isDone); to forcibly wait till the clip is loaded. What am I doing wrong here?

Secondly, some songs will never load too. After extensive testing I found out that almost 5 out of 200 songs don't load. Also even if the audio isn't loaded audClip doesn't return a NULL value which suggests that something is being loaded, however

             Debug.Log("No of Samples : "+audClip.samples);
             Debug.Log ("Frequency : " + audClip.frequency);
             Debug.Log("No of channels : "+audClip.channels);
             Debug.Log("No of length : "+audClip.length);

all four values return 0. I believe this problem is related to yield not working properly.

Any help here would be much appreciated.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CahMan · Apr 03, 2013 at 02:48 PM

For the WWW problem:

It sounds like you are calling the function instead of starting a coroutine. Here's the link to the docs, but in short:

 //Do this
 StartCoroutine(LoadSong());
 
 //Instead of this
 LoadSong();


For the songs not loading:

If some of the songs work, but other don't, I don't think it's a problem with the WWW fetch. Maybe there is something different about the files themselves (size, format, etc). Just a guess.

~C

Comment
Add comment · Show 1 · 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 VivekD · Apr 04, 2013 at 12:00 PM 0
Share

Okay, is there any way to get WWW working on PC? Say I have an mp3 in my d:/songs/ folder, how do I use WWW to retrieve that?

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

11 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

Related Questions

www.getAudioClip() Bug: One Second being cut off MP3. 2 Answers

WWW Audio and PlayOneShot: Playing the same AudioClip Twice Cuts off First Instance 1 Answer

WWW.audioClip error: Unable to determine the audio type from the URL 1 Answer

Unable to import songs using NAudio 1 Answer

www AudioClip returning incorrect length 1 Answer


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