Skip to content

Commit 81a7794

Browse files
committed
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.
1 parent 7fbb2b1 commit 81a7794

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

framework/src/org/apache/cordova/CordovaActivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2020

2121
import java.util.ArrayList;
2222
import java.util.HashMap;
23+
import java.util.Locale;
2324
import java.util.concurrent.ExecutorService;
2425
import java.util.concurrent.Executors;
2526

@@ -346,9 +347,11 @@ public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, Cor
346347
}
347348
createViews();
348349

349-
// TODO: Make this a preference (CB-6153)
350-
// Setup the hardware volume controls to handle volume control
351-
setVolumeControlStream(AudioManager.STREAM_MUSIC);
350+
// Wire the hardware volume controls to control media if desired.
351+
String volumePref = preferences.getString("DefaultVolumeStream", "");
352+
if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) {
353+
setVolumeControlStream(AudioManager.STREAM_MUSIC);
354+
}
352355
}
353356

354357
/**

0 commit comments

Comments
 (0)