Flashphoner Android SDK plays stream shows call volume slider

Umer Bhatti

New Member
Hello,

I have implemented the Flashphoner SDK in android JAVA, but the problem I am facing is that when play the stream it shows the call volume bar, I want to play the stream like music and it should show only music volume bar. Here's my code to set the audio src:

private boolean isHeadsetOn(Context context) {
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

if (am == null)
return false;

AudioDeviceInfo[] devices = am.getDevices(AudioManager.GET_DEVICES_OUTPUTS);

for (AudioDeviceInfo device : devices) {
if (device.getType() == AudioDeviceInfo.TYPE_WIRED_HEADSET
|| device.getType() == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
|| device.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
|| device.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
return true;
}
}
return false;
}

private void setAudioSrc(Context context, AudioManager audioManager) {
boolean isHeadsetConnected = isHeadsetOn(context);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
audioManager.setSpeakerphoneOn(!isHeadsetConnected);
if (isHeadsetConnected && (audioManager.isBluetoothA2dpOn() || audioManager.isBluetoothScoOn()))
audioManager.startBluetoothSco();
else
audioManager.stopBluetoothSco();
}



void main(){
Flashphoner.getAudioManager().init();
AudioManager audioManager = Flashphoner.getAudioManager().getAudioManager();
setAudioSrc(StreamingService.this, audioManager);
audioManager.registerAudioDeviceCallback(new AudioDeviceCallback() {
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
super.onAudioDevicesAdded(addedDevices);
setAudioSrc(StreamingService.this, audioManager);
}

@Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
super.onAudioDevicesRemoved(removedDevices);
setAudioSrc(StreamingService.this, audioManager);
}
}, null);

}

Kindly help.
 

Max

Administrator
Staff member
Good day.
You should use Flashphoner.getAudioManager().setUseSpeakerPhone() method to switch from a phone voice speaker to a phone speakerphone (to play a stream like a music):
Code:
mAudioOutput = (LabelledSpinner) findViewById(R.id.audio_output);
mAudioOutput.setOnItemChosenListener(new LabelledSpinner.OnItemChosenListener() {
    @Override
    public void onItemChosen(View labelledSpinner, AdapterView<?> adapterView, View itemView, int position, long id) {
        String audioType = getResources().getStringArray(R.array.audio_output)[position];
        switch (audioType) {
            case "speakerphone": Flashphoner.getAudioManager().setUseSpeakerPhone(true); break;
            case "phone":
                Flashphoner.getAudioManager().setUseBluetoothSco(false);
                Flashphoner.getAudioManager().setUseSpeakerPhone(false);
                break;
            case "bluetooth": Flashphoner.getAudioManager().setUseBluetoothSco(true); break;
        }
    }
 
    @Override
    public void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView) {
 
    }
});
See Media Devices example code.
 

Umer Bhatti

New Member
Hello,

Still having the same issue when stream gets connected it shows call volume bar besides media volume bar. Stream is playing as call audio even in loud speaker. When stream gets started if I use side volume buttons it shows in-call volume in volume bar.
 
Last edited:

Max

Administrator
Staff member
Stream is playing as call audio even in loud speaker. When stream gets started if I use side volume buttons it shows in-call volume in volume bar.
This is WebRTC library implementation behaviour. We can't change that.
 
Top