Android我想流式传输音频

时间:2017-05-07 16:41:35

标签: android audio

我正在写一个音频串行代码,但我不能带来更多。

我想使用AudioTrack。

track.write(baiss);

DatagramSocket serverSocket = new DatagramSocket(port);
                byte[] receiveData = new byte[1280];
                int N = AudioRecord.getMinBufferSize(sampleRate,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
                track = new AudioTrack(AudioManager.STREAM_MUSIC,sampleRate,AudioFormat.CHANNEL_OUT_MONO,AudioFormat.ENCODING_PCM_16BIT,N*10,AudioTrack.MODE_STREAM);
                track.play();

                while(true)
                {
                    DatagramPacket receivePacket = new DatagramPacket(receiveData,receiveData.length);
                    serverSocket.receive(receivePacket);
                    ByteArrayInputStream baiss = new ByteArrayInputStream(receivePacket.getData());

                    ... THIS CODE


                    Log.e("LOG","DATA ALINIYOR...");
                    Log.e("LOG","DATA : " + baiss.toString());

                }

0 个答案:

没有答案