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 CristianKhalil · Feb 27, 2014 at 02:28 PM · androidplaystreamingmp3notworking

Mp3 Streaming on android

Hello,

I'm trying to do a mp3 streaming from sdCard in android, but it is not working, it just work when i set streaming=false but there is a huge delay and when i try to load a second file the application stops. On editor it works perfectly, just on android it not.

Does anyone know how can i solve this? Thanks (Sorry about the english)

 public AudioSource player1;
     public AudioSource player2;
 
     private AudioClip clip1;
     private AudioClip clip2;
 
 
     void Start() {
 
     }
 
     void Update() {
 
     }
 
     public void Play(string file){
 
         if(!player1.isPlaying){
 
             loadFile(file, 1);
 
             if(player2.isPlaying)
                 DecreaseVolume(2);
 
 
             while(!player1.clip.isReadyToPlay){
                 Debug.Log("waiting1...");
             }
 
             player1.Play();
 
             IncreaseVolume(1);
 
         }else{
 
             loadFile(file, 2);
             
             if(player1.isPlaying)
                 DecreaseVolume(1);
 
             while(!player2.clip.isReadyToPlay){
                 Debug.Log("waiting2...");
             }
         
             player2.Play();
 
             IncreaseVolume(2);
         }
 
     }
 
     private void loadFile(string path, int player){
         WWW www = new WWW("file://"+path);
 
         AudioClip myAudioClip = www.GetAudioClip(false, true, AudioType.MPEG);
 
 
         if(player == 1)
             player1.clip = myAudioClip;
 
         if(player == 2)
             player2.clip = myAudioClip;
 
     }
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
1

Answer by JeffreyD · Feb 27, 2014 at 03:21 PM

Hi, The following talks about how to avoid lag when using WWW etc.. but not on Android. It looks as if it would work thought.. Perhaps it will help. http://answers.unity3d.com/questions/22170/how-to-avoid-lag-when-using-www-class-to-download.html

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 CristianKhalil · Feb 27, 2014 at 06:07 PM 0
Share

Thanks for the reply But i need to load the files from a external storage

avatar image JeffreyD · Feb 27, 2014 at 09:26 PM 0
Share

Everything I read says you can use WWW to read in an external audio file from storage as long as you know the data path. I've not tried it yet on Desktop or on $$anonymous$$obile yet. It's on my to-do list and I've only done some $$anonymous$$imal research, hence my draw to your question. Here is another thread discussion. On page 2 a few guys say they have it running. http://forum.unity3d.com/threads/140088-Importing-audio-files-at-runtime If you find anything useful in your own searching please attach a comment. I will do the same. Thanks.

avatar image JeffreyD · Feb 27, 2014 at 09:34 PM 0
Share

Just found this one. http://answers.unity3d.com/questions/517837/how-to-play-mp3-mp4-files-on-the-local-disk.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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

can't load music (wav and mp3 ) on android but the code works fine in editor and window build 0 Answers

Specific Market to be allowed to play the game 0 Answers

Upgrade from 5.0.1 to 5.1.2f1, cannot build in android now, continued. 1 Answer

How to play a .mp4 video file in android game 7 Answers

Unity Remote is not working! 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