Android AudioRecord to Server over UDP Playback Issues

前端 未结 2 653
野趣味
野趣味 2020-12-12 17:06

I am trying to make a simple Android application that streams live microphone audio to a server for playback. The resulting playback sounds strange, with large gaps in the a

相关标签:
2条回答
  • 2020-12-12 17:27

    Thanks for post Joshua .... great help for new bees :)

    volumeControl.setValue(volumeControl.getMaximum());
    
    removes illegalStateException at Server
    

    and permission in android client

    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    
    0 讨论(0)
  • 2020-12-12 17:34

    Here's something you could try, instead of:

    // read the data into the buffer
    recorder.read(buffer, 0, buffer.length);
    
    // place contents of buffer into the packet
    packet = new DatagramPacket(buffer, buffer.length, serverAddress, PORT);
    

    Do not expect you received fully read buffer from recorder but use actual read value instead

    // read the data into the buffer
    int read = recorder.read(buffer, 0, buffer.length);
    
    // place contents of buffer into the packet
    packet = new DatagramPacket(buffer, read, serverAddress, PORT);
    

    Or something alike.

    0 讨论(0)
提交回复
热议问题