AudioDemo
AudioDemo copied to clipboard
从FileInputStream读取数据,判断多余.
byte[] tempBuffer = new byte[bufferSize]; int readCount = 0; while (dis.available() > 0) { readCount = dis.read(tempBuffer); if (readCount == AudioTrack.ERROR_INVALID_OPERATION || readCount == AudioTrack.ERROR_BAD_VALUE) { continue; } if (readCount != 0 && readCount != -1) { audioTrack.play(); audioTrack.write(tempBuffer, 0, readCount); } }
readCount不需要跟ERROR_INVALID_OPERATION/ERROR_BAD_VALUE比较吧