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.
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.