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 parahunter · Jul 13, 2010 at 11:15 AM · audiowwwlagaudioclipstreaming

How to avoid lag when using WWW class to download sound

i have the following code to load a sound from a server that works:

string url = "some url";

         WWW www = new WWW(url);

         yield return www;

         atmosphereClips[scene][mood][sound] = www.oggVorbis;

But the problem with this code is that it lags a lot when it comes to "AudioClip someAudioClip = www.oggVorbis;" and it is not that big an ogg file that is being downloaded. I think it is because Unity

I have also tried to use WWW.audioClip which does not lag but as I have to download more than one sound in succession (to fill the atmosphereClips array) I don't think I can use that. I have not been able to detect when it was finished at least.

Hope someone has a better, more lag free way to do this.

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

3 Replies

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

Answer by springer · Jul 26, 2010 at 10:41 PM

from the answer:

http://answers.unity3d.com/questions/2422/yield-on-www-or-assetbundlerequest-or-both

i managed to prevent a lag when loading some audio with this (needs Unity pro for making asset bundle)

var Audiosrc : AudioSource; Audiosrc = GetComponent(AudioSource); var req : AssetBundleRequest;

function Start () {

var www = new WWW ("http://path_to_Unity_assetbundle/tortoise02.unity3d"); yield www;

req = www.assetBundle.LoadAsync ("tortoise02", AudioClip); yield req;

//Audiosrc.clip = www.assetBundle.LoadAsync ("tortoise02", AudioClip).asset; Audiosrc.clip = req.asset;

if(!Audiosrc.isPlaying && Audiosrc.clip.isReadyToPlay){ Audiosrc.Play();

} }

Comment
Add comment · 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
0
Best Answer

Answer by parahunter · May 18, 2011 at 06:05 AM

The end solution proved to be to place the sound in the scene being loaded and only switch over to it when it had been completely loaded.

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

Answer by poncho · May 17, 2011 at 01:27 PM

why dont you have that sound on client side, to avoid the Download, and avoid the bandwidth used for the download, i think that could help

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

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

No one has followed this question yet.

Related Questions

Endless Audio streaming (Radio)?! 3 Answers

How to have www streaming to work with a radio station? 1 Answer

WWW class streaming high RAM usage 0 Answers

How do i stream music from a server? 0 Answers

Get AudioClip from Path?,How to get AudioClip from a path? 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