From 81a77949fcdc58617423e69f70d74384356873cc Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 27 Nov 2014 10:52:19 -0500 Subject: [PATCH] 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. --- framework/src/org/apache/cordova/CordovaActivity.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 3c12a97a..816b12b9 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -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); + } } /**