CB-6153 Add a preference for controlling hardware button audio stream (DefaultVolumeStream)

This, along with the commit to the audio plugin, makes it so that by
default apps control the ringer volume, but when any audio players are
active, the media volume is controlled.
This commit is contained in:
Andrew Grieve 2014-11-27 10:52:19 -05:00
parent 7fbb2b195f
commit 81a77949fc

View File

@ -20,6 +20,7 @@ package org.apache.cordova;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -346,9 +347,11 @@ public class CordovaActivity extends Activity implements CordovaInterface {
}
createViews();
// TODO: Make this a preference (CB-6153)
// Setup the hardware volume controls to handle volume control
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// Wire the hardware volume controls to control media if desired.
String volumePref = preferences.getString("DefaultVolumeStream", "");
if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) {
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
}
/**