Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Stream .m3u radio

Discussion in 'Scripting' started by Tarzan111, Apr 5, 2016.

  1. Tarzan111

    Tarzan111

    Joined:
    Oct 8, 2014
    Posts:
    72
    Hi,
    I'm trying to stream radio station in my apps for sound background.
    Unfortunately most of the radio have http://linklinklink.m3u and i really have problem to do it.
    There is my code :

    Code (CSharp):
    1.  
    2.   private string url = "http://www.listenlive.eu/bbc1xtra.m3u";
    3.     void Start () {
    4.         StartCoroutine(DownloadAndPlay(url));
    5.     }
    6.     IEnumerator DownloadAndPlay(string str)
    7.     {
    8.         WWW www = new WWW(str);
    9.         yield return new WaitForSeconds(2);
    10.         if(string.IsNullOrEmpty(www.error) == false)
    11.         {
    12.            Debug.Log("Did not work");
    13.            yield break;
    14.         }
    15.         AudioSource source = GetComponent<AudioSource>();
    16.         source.clip = www.GetAudioClip(false,true);
    17.         source.Play();
    18.     }
    If i try to add AudioType format :
    Code (CSharp):
    1. source.clip = www.GetAudioClip(false,true,AudioType.I-TRIED-IT-ALL;-) );

    Is there anyway to stream .m3u files? If there is a plugin on the asset store, i'd be happy to spend my $$$. It must works on mobile devices.

    Thanks
     
  2. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    Google told me that m3u is a playlist and not a audio file so the m3u file should contain the links to the files you want :)
     
  3. Tarzan111

    Tarzan111

    Joined:
    Oct 8, 2014
    Posts:
    72
  4. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
  5. Tarzan111

    Tarzan111

    Joined:
    Oct 8, 2014
    Posts:
    72
    I don't think this project works on streaming and on Mobile device.
     
  6. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    I saw an asset pack that does this for windows phone and builds. Might be able to get ideas from source how to get it to work on others.. I think it was called Radio Pro or something like that.. They have a cheaper version but to get source you have to buy the pro one.
     
  7. Tarzan111

    Tarzan111

    Joined:
    Oct 8, 2014
    Posts:
    72
    Thanks Shawn67 but it looks like the "Radio Pro" is only working on windows computer (using dll)
     
  8. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    No... the cheap one is DLL if you read bottom of description it says the difference is pro you get full source.. Almost 100% sure.. Going back to look now. If it is like some assets, they may still have the DLL in the package but they provide the c# source in a zip file... ORK Framework is like that.. Will edit this post after I find it and look.

    EDIT: Quote at bottom of product description: "Information about this edition:
    This is the PRO edition (full source code) of the asset. If you only need the DLL-version, consider buying the Standard edition." And if you scroll through files you can see all the .cs source files.

    One thing I didn't think of though. It might be that it only supports windows because it uses the windows .net libraries or something. Would definitely be worth contacting the publisher to find out if he is using Windows only libraries to access and play the streams or if he is using standard code that should also work with other mobile platforms as well.

    If you do contact him, would be curious to hear what you find out. I threw that on my wishlist a couple days ago to maybe use in a future project.
     
    Last edited: Apr 7, 2016