Can someone help me find some way to find the amplitude of another audio player in the app? I need to know the amplitude of the videoCall sound in my application.
An example in my application I have a videoPlayer (youtube) and videoCall function. Therefore, when I receive videoCall, I need to slow down / stop the sound of the video player when someone speaks on videoCall. Is there any way to find this?
I found a way to get the amplitude of the phone audioPlayer, but this provides the amplitude of playback of all kinds of audio in the application without sending a source identifier or streamType ( MUSIC_STREAMor CALL_STREAM) or any other thing with which I can identify the source of a given amplitude, such as its player or video cards.
This will only help if I provided the audioSessionId AudioPlayer in Visualizer (audioSessionId), but I cannot get the audioSessionId of any player (videoCall, youtube) due to ThirdPartySDK.
private void createVisualizer(){
int rate = Visualizer.getMaxCaptureRate();
Visualizer audioOutput = new Visualizer(0);
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);
Log.d("rate", String.valueOf(Visualizer.getMaxCaptureRate()));
audioOutput.setEnabled(true);
}
Any suggestion would be helpful, thanks in advance.
source
share