Audio Manager

Martin Beukes

Member
Licensed User
Longtime User
Hi,

I think this is a quick and easyish one. I need to be able to get info from the audio manager and select the output manually.

This post covers most of what I think I need: https://stackoverflow.com/questions/31909040/android-force-hdmi-audio

B4X:
AudioManager manager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);   
Log.d(TAG, "ATTACHED: " + manager.getParameters("attached_output_devices"));
Log.d(TAG, "DEFAULT: " + manager.getParameters("default_output_device"));
Log.d(TAG, "PRE: " + manager.getParameters("audio_devices_out_active"));       
manager.setParameters("audio_devices_out_active=AUDIO_DEVICE_OUT_AUX_DIGITAL");
Log.d(TAG, "POST: " + manager.getParameters("audio_devices_out_active"));

 audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
    audioManager.setParameters("audio_devices_out_active=AUDIO_CODEC");
    // or
    audioManager.setParameters("audio_devices_out_active=AUDIO_HDMI");
    // or
    audioManager.setParameters("audio_devices_out_active=AUDIO_HDMI,AUDIO_CODEC");

Basically, I want to be able to check the connection of the audio outputs and then to force it out on the headphones on hdmi as required.

Thanks
Martin
 
Top