Search Unity

Load and Play an MP3 at runtime

Discussion in 'Editor & General Support' started by murkantilism, Jan 14, 2014.

  1. murkantilism

    murkantilism

    Joined:
    Apr 30, 2012
    Posts:
    21
    Hello everyone!

    I've been doing a fair amount of research as well as trial error over the past few days. Thus far I haven't found a cross platform solution for this problem: I have a file browser implemented, and I'd like to let users select an MP3 on their iOS, Android, or PC/Linux/Mac device and then auto-generate a level based on the BPM meta data (similar to AudioSurf). Apparently taking an MP3 file and doing things with it at runtime is a very complex endeavor in Unity. I found a number of threads about the topic (here, here, and here), but no concrete cross-platform solutions.

    Anyone here able to point me in the right direction, or detail a solution on how to handle MP3's at runtime? (I'm not worried about the level auto-generation, that's much easier and partially completed anyways).
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Well, Unity has no license for decoding mp3 files. On platforms where mp3 files can be played we use the hardware or software that the device has. Thus on iOS you can play back mp3 files because it's something Apple support. However you cannot usually extra the audio from the mp3.
     
  3. murkantilism

    murkantilism

    Joined:
    Apr 30, 2012
    Posts:
    21
    Well in this UA thread, it seems someone found a solution to do exactly what I want across all 3 platforms. I unfortunately haven't any idea what PCMCallBack is, or which Android plug-in dave_mm0 alluded to in that thread.

    Regarding Unity not having a license to decode Mp3 files - There are nifty tools to decode MP3 files like Mp3Sharp - are you saying that if I were to use them I would be breaking some license with Apple?