D
D
Dmitry Korolev2018-06-01 17:16:15
Unity
Dmitry Korolev, 2018-06-01 17:16:15

How to stream mp3?

I have been facing this for a long time and I can’t seem to get out of this situation, what should I do?
Streaming of 'mp3' on this platform is not supported
UnityEngine.WWW:GetAudioClip(Boolean, Boolean, AudioType)
c__Iterator0:MoveNext() (at Assets/Scripts/MusicPlayer/MusicPlayer.cs:192)

IEnumerator DownloadAndPlay(Track trackOb, int index)
  {
    nameLabel.text = trackOb.name;
    if (StaticSettings.language == 2f)
      statusLabel.text = "Buffering...";
    else 
      statusLabel.text = "Буферизация...";
    www = new WWW(trackOb.url);
    while (!www.isDone) 
    {
      yield return new WaitForEndOfFrame();
    }
    if (trackOb.format == "wav")
      source.clip = www.GetAudioClip(false, true, AudioType.WAV);
    else if (trackOb.format == "ogg")
      source.clip = www.GetAudioClip(false, true, AudioType.OGGVORBIS);
    else if (trackOb.format == "mp3")
      source.clip = www.GetAudioClip(false, true, AudioType.MPEG);
    source.clip.name = trackOb.name;
    source.time = 0f;
    sldSeek.value = 0f;
    source.Play();
    if (StaticSettings.language == 2f)
      statusLabel.text = "Playing...";
    else 
      statusLabel.text = "Проигрывается...";
    isPaused = false;
    next = true;
    playlistTracks[index].duration = source.clip.length;
    StartCoroutine(PlayerUpd());
    DrawDisplay();
  }

ogg and vav loads, but mp3 does not

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2018-06-01
@adressmoeistranici

Well, not supported can be solved in 3 ways:
1) Write supported code.
2) Search for an asset.
3) Wait until it becomes supported.
It seems like there is a plugin here - https://www.assetstore.unity3d.com/#!/content/42677

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question