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
1
Question by zero3growlithe · Dec 08, 2012 at 07:00 PM · playermusicread

Play an array of audioclips from HDD.

I wanted to make a music player for my game which allows player to put his music into Music folder in game files and i have everything done, search for files -> make an array -> stream first track -> Play with audio source and the problem is that it does not play it, no sound after setting audio.clip and audio.Play() commands, no errors in compiler, any ideas? Thx in advance! Here's my code:

 private var IsAnyMusicInFolder : boolean = false;
 private var CheckMusicFolder : boolean = false;
 private var ReadyToPlay : boolean = false;
 private var MusicTrackID : float = 0;
 function LoadMusicFromMusicFolder (){
     var info = new DirectoryInfo(Application.dataPath+"/Music");
     if (info == null){CheckMusicFolder = true;}else{
         var fileInfo = info.GetFiles("*.ogg");
         MusicFilesFromExtSrc = new WWW [fileInfo.length];
             if (!CheckMusicFolder && fileInfo.length > 0){
                 for (i=0; i < fileInfo.length; i++){
                     var ExtMusicFile : WWW = new WWW (Application.dataPath+"/Music"+fileInfo[i]);
                     MusicFilesFromExtSrc[i] = ExtMusicFile;
                     print (MusicFilesFromExtSrc[i]);
                 }
                 IsAnyMusicInFolder = true; CheckMusicFolder = true;
             } else {CheckMusicFolder = true;}
             if (CheckMusicFolder && IsAnyMusicInFolder){
                 if (!audio.IsPlaying){
                     audio.clip = MusicFilesFromExtSrc[MusicTrackID].GetAudioClip(false, false);
                     audio.Play();
                 }
                 print (audio.clip);
             }
     }
 }
Comment
Add comment · Show 2
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 T27M · Dec 09, 2012 at 12:27 AM 0
Share

Is the audio source too far away from the listener?

avatar image zero3growlithe · Dec 09, 2012 at 05:13 PM 0
Share

It doesn't matter, AudioClip.GetAudioClip(); converts streamed audio to 2D audio.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Statement · Dec 10, 2012 at 10:55 PM

Try making a Coroutine that yield www; It looks like you have specified a file to steam/download but never initiated the download.

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 Statement · Dec 10, 2012 at 10:59 PM 0
Share

Actually, looking at the docs at http://docs.unity3d.com/Documentation/ScriptReference/WWW.GetAudioClip.html I see that it could use examples. If you come across places in the documentation that you can't find examples for, you could send a bug report via Unitys bug reporter and file a Documentation Bug Report. State what information is missing and our docs $$anonymous$$m will try and improve the information. But please make sure to set the bug type to documentation bug before you hit send!

http://answers.unity3d.com/questions/9292/how-do-i-report-a-bug-in-unity.html

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

Unity and IOS Music Player 0 Answers

error CS1729: The type `UnityEngine.Rect' does not contain a constructor that takes `5' arguments 1 Answer

How to make volume continually go down in C#Script ? 1 Answer

iOS Music Control 0 Answers

How to access Android music library? 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