Can any one please help me to find any way to find amplitude of different audioPlayer with in app? I need to know the amplitude of videoCall's audio in my app.
Example in my app I have a videoPlayer (youtube) and videoCall feature. So when I get videoCall, I need to slow/stop the videoPlayer's sound when someOne speaks on videoCall. Is there any way to find that?
I found a method to get amplitude of phone's audioPlayer, but this provides amplitude of all kind of audios playing in app without sending any identifier of source or streamType(MUSIC_STREAM
or CALL_STREAM
) or any thing different using which I can identify source of given amplitude like its of player or videoCalls.
This will only help if I will provide audioSessionId of AudioPlayer in Visualizer(audioSessionId), but I can't get audioSessionId of any player (videoCall, youtube), because of ThirdPartySDK.
private void createVisualizer(){
int rate = Visualizer.getMaxCaptureRate();
Visualizer audioOutput = new Visualizer(0); // get output audio stream
audioOutput.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
@Override
public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {
float intensity = ((float) waveform[0] + 128f) / 256;
Log.d("visualizer = ", "visualizer = "+visualizer+ "visualizer = "+String.valueOf(intensity));
}
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
}
},rate , true, false); // waveform not freq data
Log.d("rate", String.valueOf(Visualizer.getMaxCaptureRate()));
audioOutput.setEnabled(true);
}
Any suggestion would be helpful, Thanks in advance.