I have two byte arrays. One contains background music and the second contains recorded voice.
How could I combine them into single array and play that with a MediaPlayer?
I was trying to do next:
1)
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if (array1 != null && array1 != 0)
outputStream.Write(array1);
if (array2 != null && array2 != 0)
outputStream.Write(array2);
return outputStream.ToByteArray();
2)
byte[] joinedArray = Arrays.CopyOf(array1, array1.Length + array2.Length);
Array.Copy(array2, 0, joinedArray, array1.Length, array2.Length);
return joinedArray;
In both cases I receive not merged array (only voice or only music is played if I pass that to the MediaPlayer).
Thanks in advance.