Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
4
Question by Robon · Sep 26, 2011 at 06:59 PM · audiomusicstreaming

Streaming music

Is it possible to play audio streams in Unity 3D?

Comment
Add comment · Show 7
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 Robon · Sep 27, 2011 at 04:32 AM 2
Share

Thanks for the answer Sven. That is the approach I was taking as I am currently on Indie. Any idea where I am going wrong?

var url : String = "http://91.121.72.50:9106/";

function Start () {

 var www : WWW = new WWW (url);    // start a download of the given URL
 audio.clip = www.GetAudioClip(false, true); // 2D, strea$$anonymous$$g
 audio.Play();

}

avatar image Sren Christiansen · Sep 27, 2011 at 02:50 PM 0
Share

you should check the audio.clip.IsReadyToPlay() is true before playing

avatar image Robon · Sep 27, 2011 at 05:51 PM 0
Share

The audio clip will not have an end though as it is a live stream

avatar image Sren Christiansen · Sep 27, 2011 at 06:33 PM 0
Share

IsReadyToPlay will return true after it has enough data to play (~2k depending on the format). Beware you'll end up running out of memory if you stream in endless stream. Unless you destroy the AudioClip once in awhile though.

avatar image Robon · Sep 27, 2011 at 07:35 PM 1
Share

when I run this code it always reports that IsReadyToPlay is false.

var url : String = "http://radio.108.pl:8006/ambient.ogg";

function Start () {

 var www : WWW = new WWW (url);  // start a download of the given URL

 audio.clip = www.GetAudioClip(false, true); // 2D, strea$$anonymous$$g

}

function Update() {

 if (!audio.isPlaying && audio.clip.isReadyToPlay)

 {

     audio.Play();

 }

 else

 {

     Debug.Log("waiting - isplaying : " + audio.isPlaying + " isreadyToPlay : " + audio.clip.isReadyToPlay);

 }

}

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by J3-Gaming · Sep 26, 2011 at 09:35 PM

Yes you can:

http://unity3d.com/support/documentation/ScriptReference/MovieTexture.html

If no movie is needed, just leave it blank, you can still access the audioClip property.

Mobile phone solution: http://unity3d.com/support/documentation/ScriptReference/iPhoneUtils.html

Comment
Add comment · Show 5 · 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 J3-Gaming · Sep 26, 2011 at 09:36 PM 0
Share

You have to script the assignment, gameObject.audioClip = downloaded$$anonymous$$ovieTexture.audioClip;

and then play the audio from the stream

avatar image BerggreenDK · Sep 26, 2011 at 09:45 PM 0
Share

I've deleted my answer as I was mistaken. Just wondering, is this also working on Indie version? There is no $$anonymous$$oviePlayback on the free version as I recall, so I was wondering if the strea$$anonymous$$g will work or not?

avatar image J3-Gaming · Sep 26, 2011 at 10:26 PM 0
Share

oh right, sorry to say I know of this solution as "Pro Only"

$$anonymous$$aybe the other answer with WWW would work, I think both could get you to the same goal. This one is more if you wanted video with audio, and I think WWW would be audio only.

avatar image ina · Dec 13, 2011 at 03:17 AM 0
Share

Do iPhoneUtils work on Android?

avatar image ina · Dec 13, 2011 at 08:24 AM 0
Share

mp3 is not supported for iPhoneUtils Android

avatar image
0

Answer by Sren Christiansen · Sep 26, 2011 at 09:43 PM

Yes, use the WWW class and the function: function GetAudioClip (threeD : boolean, stream : boolean) : AudioClip and specify the 'stream' parameter to true.

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 FWCorey · Aug 03, 2012 at 06:20 AM

You can also put it on a single GameObject in an otherwise empty Scene then use Application.LoadLevelAdditiveAsync to stream it if this is for a WebPlayer build. I've used this method myself and it works fine.

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

7 People are following this question.

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

Related Questions

Building a browserbased venue with streaming audio 0 Answers

Stream music in Unity mobile 0 Answers

Streaming Music from Disk 1 Answer

Background Music 3 Answers

Music Zones play music with tags? 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