Play audio from byte array

Hey guys,

I’ve searched around a bit, but didn’t find anything helpful. If I missed something, please let me know!
Anyway, I have an encrypted wav file that I want to play using Unity’s built-in audio system. The issue is that once I decrypt it, it can’t be within reach of the user, so I have to keep it as a byte array. But, I can’t find any way to play audio from a byte array, and that’s my issue.

So, if you have any suggestions, tips, comments, et cetera, please let me know!

Thanks for taking the time to read this! - Gibson

1 Answer

1

You could make an asset bundle with your (decrypted) sound file. Then encrypt the bundle file.

To play, load that file into memory, decrypt it at runtime and use CreateFromMemory to access your asset. Then you could load the audio source and play it. Just an idea.

edit----

Or you could load your custom data, decrypt it, then convert the byte array to a float array. Then you can create an audio clip and fill it with your float data.

oh!Just Give this to JAVA or IOS API can achieve your goal。

I have encountered this problem,THE audio I use to Play is down from server as Byte[]。My solution is Give this to JAVA or IOS API。Sometimes, You will find that you must Convert the simple things To asset bundle ......Oh,Fuck the Shit asset bundle