在通话过程中播放音频文件,但在另一端的人是不是能听到它(Play audio file during

2019-07-30 19:30发布

我想在通话过程中播放的音频文件,我可以发挥,但是当我拨打电话,只对我所安装的应用程序,设备上播放文件。 这里是我所播放的音频文件,我的示例代码。

 public void play() {

    bufferSize = AudioTrack.getMinBufferSize(16000,
            AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);

    AudioTrack at = null;
    at = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
            16000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
            AudioFormat.ENCODING_PCM_16BIT, bufferSize, AudioTrack.MODE_STREAM);

    String filePath = Environment.getExternalStorageDirectory()
            .getAbsolutePath();
    String file = filePath + "/" + "myfile.wav";

            int i = 0;
    byte[] s = new byte[bufferSize];
    try {
        FileInputStream fin = new FileInputStream(file);
        BufferedInputStream bis = new BufferedInputStream(fin, 44000);
        DataInputStream dis = new DataInputStream(bis);

        at.play();

        while ((i = dis.read(s, 0, bufferSize)) > -1) {
            at.write(s, 0, i);

        }

        at.stop();
        at.release();
        dis.close();
        fin.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

此代码工作正常我。 但我想,这个文件将能够通过另一端的人谁拨打电话听到。 我怎么能做到这一点??? 任何的想法?? 我知道Android的API不允许做任何it..but谁做的? 请给只有真正的和准确的答案不是假设。

文章来源: Play audio file during a call, however the person on the other end is not able to hear it