Search Unity

Radio PRO - MP3 and OGG-streaming solution

Discussion in 'Assets and Asset Store' started by Stefan-Laubenberger, Jun 18, 2015.

  1. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Does this work on WEBGL?
    When the sale end
     
    Last edited: Aug 10, 2017
  2. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Currently not, but we're working on it and I think it will soon be ready.
    One of the main problems is that many stations still use http instead of https...

    So long,
    Stefan

    Edit:
    The sale has ended :(
     
    Last edited: Aug 11, 2017
  3. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    We've created a new promotion video:



    Have a nice weekend!


    Cheers
    Stefan
     
  4. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Nice promo video, very professionally done.
     
    Stefan-Laubenberger likes this.
  5. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Thank you very much!
     
  6. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    We created a new tutorial video:




    Cheers
    Stefan
     
    Last edited: Nov 11, 2017
  7. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi Stefan,

    1) I want to use a real radio game object that is placed in room environment, cinema, club, shop or anywhere.
    Eg. The player should be set some radio stations simply.

    But the problem in this case is the sound because it does not fit with the game environment.

    I'd like the stream running through a unity audio object where I can set the frequency filter (low and high pass or parametric is required), pan, mono and volume until it's off. It's required to change the sound of the stream while the player move away, leave a room, drive by or any other situation.

    In the most cases a low bitrate of 32Kb or 64kb in mono is fully enough in my case.
    Would it be possible lower the incoming bitrate of a stream?

    2) What happen in a build if the stream get's lost or I cut the online connection? :)
    Does the player freeze? Is it save that any chunk of the stream does not loop for ever?

    A good thing would be to buffer the stream for a second. On lost the stream it can be fade out.

    Thank you!
     
    Last edited: Sep 11, 2017
  8. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    I try to answer your questions:

    1) Can be done with Radio, it's an AudioSource and can be configured with spatial blending for 3D and reverb filters.
    The second part isn't possible. You have to use streams with the desired bitrate.

    2) No, that would be very unprofessional... Radio stops the playback and notifies you via the "OnError"-callback.
    We have a buffering system included, no worries :)

    I hope this helps you further. If you have additional questions, don't hesitate to ask.


    Cheers
    Stefan
     
  9. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    ...
     
    Last edited: Sep 12, 2017
  10. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    You removed the content of your post, but I still answer it :)

    Most professional stations are using http://icecast.org/
    That's also my recommendation.


    Cheers
    Stefan
     
  11. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Hi Stefan,

    I post this question here (not email) because other users may find the information useful.

    I am writing the scrolling credits text for my game, I realize I am not obliged to credit you, but would like to anyway, your product being so nice.

    would a string like below be good for you?

    Feel free to add any other info etc.
     
    Stefan-Laubenberger likes this.
  12. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Thank you very much, this is awesome! :)
    Please send me a link to your game.

    Have a nice weekend!


    So long,
    Stefan
     
    SiliconDroid likes this.
  13. ShadLandProjects

    ShadLandProjects

    Joined:
    Feb 24, 2015
    Posts:
    33
    hi. I was wondering if there is a way on the android version to have the music keep playing even if you are not in the app. like maybe supporting background playing of the app?

    Thanks
    Shad
     
  14. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi Shad

    Yes, we included a manual in the asset which explains the necessary steps for iOS and Android.


    Cheers
    Stefan
     
  15. ShadLandProjects

    ShadLandProjects

    Joined:
    Feb 24, 2015
    Posts:
    33
    ok and it will keep the music playing when the app is closed correct?
     
  16. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    As long as it's in the background - by closed I understand "terminated".
    But be aware of the fact, that it won't replace a pure native solution, since Unity is still working in the background which leads to a higher power consumption...
     
  17. ShadLandProjects

    ShadLandProjects

    Joined:
    Feb 24, 2015
    Posts:
    33
    if it plays in the background (when app is not opened. aka music plays while browsing other apps) then i will buy it tomorrow.
     
  18. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Yes, that will work. :)
    But you have to start the app first before browsing other apps. And you have to be aware of the mobile limitations, like Android will kill the app if you run out of memory...
    Also: we tested only Android 4, 5 and 6 - it's possible that newer versions won't work with the "trick" in the manual.
     
  19. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I would like to setup my own radio station using icecast to stream mp3 music into a mobile app. I would also like to save the streamed music into the app so that the user can play the music without having access to the internet.

    Can you suggest how this can be done.

    Cheers
     
  20. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Lets discuss this in private :)
    Please send me an email.


    So long,
    Stefan
     
  21. matthewninja

    matthewninja

    Joined:
    Jun 12, 2017
    Posts:
    1
    Works great in the editor. But on an Android Samsung S8, I get "Could not read url error".. via ADB in readStream. It just flickers and errors on the phone.

    ADB points to "_errorMessage = _station.Name + System.Environment.NewLine + "Could not read url after " + Util.Helper.FormatSecondsToHourMinSec(PlayTime) + "!" + System.Environment.NewLine + ex;" in readStream(...).

    Any advice on getting it working on Android? Am I missing a setting?

    Using version of Radio Pro: 2.8.4.

    Hope this helps and thanks for the advice!
     
  22. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    "Radio" has two different MP3-decoders, one for Windows and one for "the rest". The second encoder doesn't work with all streams - this could cause the problem... Please send me the streaming URL via PM or email.

    Furthermore, please test our demo on your device:
    http://www.crosstales.com/media/radio/Radio.apk

    Does it work?


    So long,
    Stefan
     
  23. cbharara

    cbharara

    Joined:
    Aug 29, 2017
    Posts:
    2
    Do you support streaming of m3u that contain aac stream/s? We are looking for a solution to stream our own station to Android.
     
  24. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    Thank you for your interest in Radio!

    Unfortunately, Radio supports currently "only" MP3 and OGG. Support for Opus is in the pipeline, but AAC seems not so easy, since we didn't found an open-source encoder so far...
    Is it possible to deliver your streams as MP3 or OGG?


    So long,
    Stefan
     
  25. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Hi Stefan,

    I'm using Radio V2.85:

    I noticed a lag in my game every few seconds and have found the cause to be GC with radio.

    Unity build settings:
    • Android/Mono
    • Development Build
    • Autoconnect Profiler
    Running the game while the android phone is connected to my PC via USB:
    The unity profiler is showing sawtooth function for "Total GC Allocated".
    Garbage collection of 13.7Mb every 4.75s ~= 2.88 Mb/s

    This is not script related GC, script GC line remains nearly flat, I presume it's the plugin.

    When I stop the radio "Total GC Allocated" remains constant.
    When I restart the radio GC starts up again.

    I'm not sure if this is just something that happened after updating to V2.85, it's the first time I've noticed it though, so I presume it is.

    NOTE: running radio in the unity editor (windows) does not cause this GC.
     
    Last edited: Oct 23, 2017
  26. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    Radio shouldn't trigger the GC at all (or really seldom)... I'm also confused about the used memory amount - if it were a problem with Radio, I would expect it to be much lower (below 0.5Mb/s).

    Can you please tell me more about your setup? Are you using any special asset components like the "Loudspeaker"?
    Are you playing multiple stations at once?

    I'm currently on holiday until the end of the week and I've got no Android phone with me, so I can't test it right now... :(

    Meanwhile, it would be nice, if you could try those settings in the RadioPlayer-component:
    upload_2017-10-23_11-43-35.png

    1. Capture Data Stream must be disabled! Be aware that "Loudspeaker" and "StreamSaver" will re-enable it anyway... So don't use those components for your tests.
    2. Increase and decrease the Cache Stream Size, e.g. 256 and 8192
    3. Try Legacy Mode
    4. Build for IL2CPP instead of Mono
    Please let me know if you've got some news.
    I will take a look at this as soon as I have access to an Android phone.


    Cheers
    Stefan
     
    SiliconDroid likes this.
  27. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Hi,

    I tried my android build with the settings above and IL2CPP build, I got the same result.

    So I decided to try and isolate the issue and check if it wasn't something in my code that was somehow causing it.

    I created a new empty unity project and imported the complete Radio V2.85 package.

    I found the issue does also exist in "PC Mac & Linux standalone" mode when running in editor, it's just that desktop is powerful enough to handle the GC without noticeable stall.

    I opened the radio demo scene "01-PlayStations", and ran it while observing the profiler.

    Below we are looking at the third graph row "Memory", the red line "Total GC allocated"

    Radio playing at pitch=1:
    Screenshot (141).jpg

    Radio playing at pitch = 3:
    Screenshot (142).jpg

    Radio not playing:
    Screenshot (144).jpg

    As can be seen the GC is proportional to the radio streaming speed.

    When I drag my mouse cursor over the "Total GC allocated" plot, unity shows me the values of the various memory stats in the info panel below: It is the "Used total: Mono" field that is changing with the "Total GC allocated" plot.

    Taking a pen/paper/stopwatch I analysed the GC as follows:

    Radio not playing (idle) = 0.24 Mb/s
    Radio playing at pitch = 1: 0.86 Mb/s
    Radio playing at pitch = 3: 2.06 Mb/s

    Subtracting the idle GC (caused by higher level C# scripting for the demo and visible in the purple plot "GC allocated") we get:

    Radio playing at pitch = 1: (0.86 - 0.24) = 0.62 Mb/s
    Radio playing at pitch = 3: (2.06 - 0.24) = 1.82 Mb/s

    Thus observing a GC increase almost exactly proportional to stream speed.

    I assume this GC is happening within the compiled mono plugin, and this is why it is not visible on the purple "GC allocated" plot, we only see its effect on the "Total GC allocated" plot.

    P.S.
    Enjoy your holiday, you should probably look at this *after* your holiday.:)
     
    Last edited: Oct 23, 2017
  28. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    I will take a look later on and try to find the source of this problem...
    Please give me some time.


    So long,
    Stefan
     
    SiliconDroid likes this.
  29. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    So, I did some tests, but I could not find the problem so far.
    On my side, the GC seems to work the same:

    Empty scene, RadioPlayer disabled:
    Radio-GC-NoPlay.PNG


    Empty scene, RadioPlayer enabled and playing:
    Radio-GC-Play.PNG

    I made a little test package with Unity 2017.2.
    You can use this to verify it on your side.

    Some questions:
    1. Are you using the PRO or standard version?
    2. Which Android device are you using?

    It bothers me since many users are using this plugin on Android without any issue. Probably your game needs a lot of resources and combined with our plugin, it leads to the experience you've got...
    Can you please build our demo scene "01" to for your device and tell me, if you "feel" any lags?

    I will investigate this further after I'm back from my holiday.
     

    Attached Files:

  30. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Hi Stefan,

    OK, I have good news for you: This issue only happens when I have radio playing and my houses wifi internet connection is poor (if i move to edge of coverage i can replicate issue), your buffering code is working so I don't hear any dropout, but some process (maybe even in a lower network scope) is causing my game to not quite make submit for one frame, every few seconds.

    I was making an assumption about the periodic TotalGC cleanup being the cause of the perceived frame drop.

    With a good internet connection I do not get this issue. The radio is fine.

    Yes, my game is mobile VR, and I'm pushing the phone to its limits, in VR one frame skip can be perceived easily if you happen to be moving the camera in translation. This would not be noticed on a regular game.

    I will upgrade my regular radio license to pro license, your attention to your products deserves it.

    All the best, Fraser.
     
    Last edited: Oct 24, 2017
    Stefan-Laubenberger likes this.
  31. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi Fraser

    Just to clarify, it wasn't my intention to "force" you into buying the PRO version. I just wanted to know which version you're using to start further investigations...
    However, l'm happy you seem to like the product and thank you for supporting us!

    I will try to optimize some of the code after my return.


    So long,
    Stefan
     
  32. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    I've got an other idea - probably you should try to tweak the chunk- and buffer size:
    Radio-cfg.PNG

    Chunk Size: 8 or 64
    Buffer Size: 128 or 256


    Cheers
    Stefan
     
  33. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    Is it possible to use this asset to stream from a private server or are we limited to public stations?
     
  34. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    You can play any MP3 or OGG stream from anywhere.
    In our demo-app, you can test your own stream in the third scene:
    Capture.PNG


    Cheers
    Stefan
     
    blacksun666 likes this.
  35. SirTwistedStorm

    SirTwistedStorm

    Joined:
    Sep 20, 2015
    Posts:
    192
    Have you heard anything from customers or in general about the legality of selling a game in the United States that plays music from the radio? I looked at the links you provided and only one say's that if you pay them you can use their service everything else talks about starting your own station and because of this I'm unsure if this would be legal in the United States without proper licensing.
     
  36. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Lets put it that way: we have hundreds of happy customers and none of the have told us about any legal issues.
    This doesn't mean, I'm sure about the legal status since I'm not a US citizen...

    But if you look at it from a "common sense perspective", Radio is just like the old thing we had in our younger days :) It plays the sound from radio stations. All those stations have a public site and/or are available on https://www.radionomy.com, http://www.shoutcast.com etc.
    This means in my understanding, they want to reach as many listeners as possible. They also have to pay for their broadcasting, so it should be covered.

    However, it's a smart move to add at least their URL/logo in the game. And if you're still unsure, just ask the stations you're planning to include in your game.
    It would also be nice, if you mention them (and us :p) in the credits and spend some money to support them. E.g. http://somafm.com is from the US and is happy to get some money!

    I hope this helps you a bit further.
    Have a nice weekend!


    Cheers
    Stefan
     
    Last edited: Nov 17, 2017
    SiliconDroid and SirTwistedStorm like this.
  37. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    As Stefan says:

    It's my understanding that online radio broadcasters want as broad an audience as possible. They would prefer it if every game had a receiving client in it; if it did the online radio broadcasting industry would increase in total market capital.

    I would recommend giving your users a large selection of stations to choose from (or perhaps have your game randomly select from a pool) sprinkle your users into the system rather than throw them all at one URL, this is the optimum way to help online radio broadcasters as a whole.
     
  38. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    I understand that Radio must be a fantastic asset to play mp3 radio stream...but for now I simply need a MP3 player to overcome the unity-windows limitation to only play ogg format!
    When I'll buy the asset, will I be able to simply play mp3 files from user local folder?
    If yes, is this a good solution to 'simply' play mp3 or is it overkill!
    Thanks
     
    Last edited: Nov 27, 2017
  39. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    Thank you for your interest in Radio!

    Yes, it can play local files, but it is intended for streams.

    But we have a new, better fitting asset ready for release - it's called DJ:
    https://forum.unity.com/threads/coming-soon-dj-play-your-music.502627/

    If you like, you can have access to a beta version. We will start the beta-program later this week.


    Cheers
    Stefan
     
  40. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Thanks for the reply! Sorry, I guess I'm not phrasing the question right: I have to play local MP3 files NOW, but would like to be able to use streaming radio on next update! Will I do both with Radio and/or DJ?
     
  41. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Yes, you can play local files with Radio.
    But there are no special file providers like in DJ, so you have to manage the files by yourself. Or you can mimic it with the existing radio station providers :)
     
  42. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Sorry to insist, but want it to be clear to me:
    My application goes into the user music folder and play random tunes from his folder...simply!
    1. Will Radio do it? Will DJ do it? (Where does reside the difference?)

    Later on, an option to play tunes from streaming radio could be added.
    2. Will Radio do it?...yes,ok ;) Will DJ do it?

    Thanks
     
  43. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    What is your target build platform?
     
  44. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Windows! As written in my first message the goal here is to FIRST overcome the fact that Unity not allows to play MP3 files on Windows THEN benefit from radio streams! ;)
     
  45. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Sorry, I have a lot of questions to answer :rolleyes:

    However, as I wrote, Radio will work and I'm happy to help you getting it up and running.
    DJ will be even better suited for your case and you could replace Radio with DJ as soon as it's available.

    I hope this clarifies the situation. You can always write me an email to discuss this further.


    Edit:
    DJ is finally released, for more please see:
    https://forum.unity.com/threads/coming-soon-dj-play-your-music.502627/
     
    Last edited: Jun 25, 2018
  46. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Thanks for the reply! I've just bought the asset ;)
     
    Stefan-Laubenberger likes this.
  47. armenthiz

    armenthiz

    Joined:
    Nov 30, 2017
    Posts:
    3
    Hi,

    I want to ask about asset radio, how to catch error like below
    Code (CSharp):
    1. Could not read url after 0:14!
    This happen when i streaming radio then the internet connection is disconnected / unstable connection.

    Thanks.
     
  48. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,981
    Hi

    You can listen to the callback "OnErrorInfo" to be informed when this happens.
    If you have an unstable connection, improve the "Buffer Size" of the RadioPlayer, like:
    Capture.PNG

    An MP3 stream normally needs 16KB/s, so the default value of 64 is for 4 seconds.
    With 128 it's therefor 8 seconds.

    You can also play with the "Chunk Size" - a lower value (like 8) could help.
    Try the best settings for your situation.

    I hope this gets you further, please let me know.
     
  49. armenthiz

    armenthiz

    Joined:
    Nov 30, 2017
    Posts:
    3
    Thanks, i'll try it.
     
  50. mkurnadi

    mkurnadi

    Joined:
    Jan 29, 2016
    Posts:
    6
    Dear Stefan,

    I am working together with @armenthiz Thanks for your prompt response.
    We are developing an android application based on crosstales Radio Asset, streaming from airtime.pro server. It almost works perfectly well until We tested our application to run the radio streaming on the background (when our application screen out of focused position). We were simulating the wifi / mobile network get disconnected by turning off the wifi / mobile network, when we switched back to our application (focused), the application crashed. However when we let our application opened all the time (focused), we did not have this issue (disconnected and connected wifi/mobile network) and our application did not crash, meaning can go offline, buffering, online with no issue. Perhaps you can provide us some guidance ?

    Thanks alot