I’m trying to allow my users to place their own music into a folder (in OGG format) in standalone builds of my game.
I have playback working by using the ‘WWW’ class with a ‘file://’ URL - this gives me an AudioClip with ‘stream’ set to true.
However, after around about 30-40 seconds of playback I start getting errors like this - ‘WWW: out of memory’.
I’m assuming this is because the WWW class is trying to extract the entire OGG track uncompressed into memory?
Is there any way that I can…
a) Force the system to load the file as COMPRESSED rather than UNCOMPRESSED (ie. the same way as checking ‘Compressed In Memory’ if I had built the sound file into my Unity project?
b) Failing that, increase the buffer size for the WWW class to allow a larger file to be downloaded?
c) Clear out the portion of the AudioClip already downloaded and played, to create more memory for incoming data?
The only other option I have is that I can manually decode the data directly with file IO and a library such as Mp3Sharp, managing the playing buffer myself via the PCMReaderCallback functions. However, I was hoping that Unity would have some out-of-the-box support for this.