From eeea5cafb712cf1d7c4724efc41d4679c98057cf Mon Sep 17 00:00:00 2001 From: shibbs Date: Thu, 28 May 2015 18:44:24 -0600 Subject: [PATCH 01/10] Update VolumeSlider.m --- src/ios/VolumeSlider.m | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/ios/VolumeSlider.m b/src/ios/VolumeSlider.m index f984e09..6895488 100644 --- a/src/ios/VolumeSlider.m +++ b/src/ios/VolumeSlider.m @@ -14,6 +14,9 @@ @implementation VolumeSlider @synthesize mpVolumeViewParentView, myVolumeView, callbackId; +float userVolume = 0.2; +UISlider* volumeViewSlider = nil; + #ifndef __IPHONE_3_0 @synthesize webView; #endif @@ -30,7 +33,8 @@ -(CDVPlugin*) initWithWebView:(UIWebView*)theWebView - (void) createVolumeSlider:(CDVInvokedUrlCommand *)command { - NSArray* arguments = [command arguments]; + NSLog(@"In createVolumeSlider"); + NSArray* arguments = [command arguments]; self.callbackId = command.callbackId; NSUInteger argc = [arguments count]; @@ -40,7 +44,7 @@ - (void) createVolumeSlider:(CDVInvokedUrlCommand *)command } if (self.mpVolumeViewParentView != NULL) { - return;//already created, don't need to create it again + // return;//already created, don't need to create it again } CGFloat originx,originy,width; @@ -68,12 +72,24 @@ - (void) createVolumeSlider:(CDVInvokedUrlCommand *)command [[MPVolumeView alloc] initWithFrame: mpVolumeViewParentView.bounds]; [mpVolumeViewParentView addSubview: myVolumeView]; self.myVolumeView.showsVolumeSlider = NO; + + + volumeViewSlider = nil; + for (UIView *view in [self.myVolumeView subviews]){ + if ([view.class.description isEqualToString:@"MPVolumeSlider"]){ + volumeViewSlider = (UISlider*)view; + NSLog(@"Found MPVolumeslider : %f" ,userVolume ); + break; + } + } + } - (void)showVolumeSlider:(CDVInvokedUrlCommand *)command { self.myVolumeView.showsVolumeSlider = YES; self.mpVolumeViewParentView.hidden = NO; + } - (void)hideVolumeSlider:(CDVInvokedUrlCommand *)command @@ -82,6 +98,22 @@ - (void)hideVolumeSlider:(CDVInvokedUrlCommand *)command self.myVolumeView.showsVolumeSlider = NO; } +- (void)maxVolumeSlider:(CDVInvokedUrlCommand *)command +{ + userVolume = volumeViewSlider.value; + self.mpVolumeViewParentView.hidden = YES; + self.myVolumeView.showsVolumeSlider = NO; + [volumeViewSlider setValue:1.0f animated:NO]; + [volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside]; + +} + +- (void)resetVolumeSlider:(CDVInvokedUrlCommand *)command +{ + [volumeViewSlider setValue:userVolume animated:NO]; + [volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside]; + +} @end From 6f74c4ccecc4d3d0ee027e0e33db7d992b8dc116 Mon Sep 17 00:00:00 2001 From: shibbs Date: Thu, 28 May 2015 18:44:42 -0600 Subject: [PATCH 02/10] Update VolumeSlider.h --- src/ios/VolumeSlider.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ios/VolumeSlider.h b/src/ios/VolumeSlider.h index fa80e2a..97c63b8 100644 --- a/src/ios/VolumeSlider.h +++ b/src/ios/VolumeSlider.h @@ -25,5 +25,7 @@ - (void)createVolumeSlider:(CDVInvokedUrlCommand *)command; - (void)showVolumeSlider:(CDVInvokedUrlCommand *)command; - (void)hideVolumeSlider:(CDVInvokedUrlCommand *)command; +- (void)maxVolumeSlider:(CDVInvokedUrlCommand *)command; +- (void)resetVolumeSlider:(CDVInvokedUrlCommand *)command; @end From 47fe740d6de52eb7309af92da85a8c0f388f5618 Mon Sep 17 00:00:00 2001 From: shibbs Date: Thu, 28 May 2015 18:45:20 -0600 Subject: [PATCH 03/10] Update VolumeSlider.js --- www/VolumeSlider.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/www/VolumeSlider.js b/www/VolumeSlider.js index c0c579f..af526a6 100644 --- a/www/VolumeSlider.js +++ b/www/VolumeSlider.js @@ -31,5 +31,19 @@ module.exports = { */ hideVolumeSlider : function() { exec(null, null, "VolumeSlider","hideVolumeSlider", []); - } + }, + + /** + * Hide the volume slider + */ + maxVolumeSlider : function() { + exec(null, null, "VolumeSlider","maxVolumeSlider", []); + }, + + /** + * Hide the volume slider + */ + resetVolumeSlider : function() { + exec(null, null, "VolumeSlider","resetVolumeSlider", []); + } }; From 0c5b2da94a04ebb27c239c36fa22587768e4b30c Mon Sep 17 00:00:00 2001 From: shibbs Date: Thu, 28 May 2015 18:49:04 -0600 Subject: [PATCH 04/10] Update VolumeSlider.js Updated the comments to reflect what is going on --- www/VolumeSlider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/VolumeSlider.js b/www/VolumeSlider.js index af526a6..42a249f 100644 --- a/www/VolumeSlider.js +++ b/www/VolumeSlider.js @@ -34,14 +34,14 @@ module.exports = { }, /** - * Hide the volume slider + * Max out the volume slider, and save the user set volume */ maxVolumeSlider : function() { exec(null, null, "VolumeSlider","maxVolumeSlider", []); }, /** - * Hide the volume slider + * Reset the volume slider to the original user volume */ resetVolumeSlider : function() { exec(null, null, "VolumeSlider","resetVolumeSlider", []); From 3b9bba420ed984f54a39d0473b80bfe408d46f67 Mon Sep 17 00:00:00 2001 From: Stephen hibbs Date: Fri, 29 May 2015 10:35:12 -0600 Subject: [PATCH 05/10] created more generic function to set the user volume, had it working briefly in my app, am committing what should be a working copy --- src/ios/VolumeSlider.h | 2 +- src/ios/VolumeSlider.m | 15 ++++++++++++--- www/VolumeSlider.js | 10 +++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/ios/VolumeSlider.h b/src/ios/VolumeSlider.h index 97c63b8..14269f8 100644 --- a/src/ios/VolumeSlider.h +++ b/src/ios/VolumeSlider.h @@ -25,7 +25,7 @@ - (void)createVolumeSlider:(CDVInvokedUrlCommand *)command; - (void)showVolumeSlider:(CDVInvokedUrlCommand *)command; - (void)hideVolumeSlider:(CDVInvokedUrlCommand *)command; -- (void)maxVolumeSlider:(CDVInvokedUrlCommand *)command; +- (void)setVolumeSlider:(CDVInvokedUrlCommand *)command; - (void)resetVolumeSlider:(CDVInvokedUrlCommand *)command; @end diff --git a/src/ios/VolumeSlider.m b/src/ios/VolumeSlider.m index 6895488..845defc 100644 --- a/src/ios/VolumeSlider.m +++ b/src/ios/VolumeSlider.m @@ -82,6 +82,7 @@ - (void) createVolumeSlider:(CDVInvokedUrlCommand *)command break; } } + userVolume = volumeViewSlider.value; } @@ -98,12 +99,20 @@ - (void)hideVolumeSlider:(CDVInvokedUrlCommand *)command self.myVolumeView.showsVolumeSlider = NO; } -- (void)maxVolumeSlider:(CDVInvokedUrlCommand *)command +- (void)setVolumeSlider:(CDVInvokedUrlCommand *)command { - userVolume = volumeViewSlider.value; self.mpVolumeViewParentView.hidden = YES; self.myVolumeView.showsVolumeSlider = NO; - [volumeViewSlider setValue:1.0f animated:NO]; + + NSArray* arguments = [command arguments]; + NSUInteger argc = [arguments count]; + + if (argc < 1) { // at a minimum we need the value to be set... + return; + } + float setVolume = [[arguments objectAtIndex:0] floatValue]; + + [volumeViewSlider setValue:setVolume animated:NO]; [volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside]; } diff --git a/www/VolumeSlider.js b/www/VolumeSlider.js index 42a249f..eb0ad6d 100644 --- a/www/VolumeSlider.js +++ b/www/VolumeSlider.js @@ -14,7 +14,7 @@ var exec = require('cordova/exec'); module.exports = { /** - * Create a volume slider. + * Create a volume slider, and save the user's current set volume. */ createVolumeSlider : function(originx,originy,width,height) { exec(null, null, "VolumeSlider","createVolumeSlider", [originx, originy, width, height]); @@ -34,14 +34,14 @@ module.exports = { }, /** - * Max out the volume slider, and save the user set volume + * Set the device's master volume */ - maxVolumeSlider : function() { - exec(null, null, "VolumeSlider","maxVolumeSlider", []); + setVolumeSlider : function(set_volume) { + exec(null, null, "VolumeSlider","setVolumeSlider", [set_volume]); }, /** - * Reset the volume slider to the original user volume + * Reset the volume slider to the original user volume present uon creation of this slider */ resetVolumeSlider : function() { exec(null, null, "VolumeSlider","resetVolumeSlider", []); From 0cea51a936ad941b43f0f95ba7a746d56a9964e2 Mon Sep 17 00:00:00 2001 From: Prayash Thapa Date: Thu, 11 Jun 2015 12:10:32 -0600 Subject: [PATCH 06/10] Add Android support (from https://github.com/battlmonstr/VolumeSlider) --- plugin.xml | 10 ++++ src/android/VolumeSlider.java | 106 ++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100755 src/android/VolumeSlider.java diff --git a/plugin.xml b/plugin.xml index f5f6ec1..e80658a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -32,5 +32,15 @@ + + + + + + + + + + diff --git a/src/android/VolumeSlider.java b/src/android/VolumeSlider.java new file mode 100755 index 0000000..7eb90ea --- /dev/null +++ b/src/android/VolumeSlider.java @@ -0,0 +1,106 @@ +package org.devgeeks.volumeslider; + +import android.content.Context; +import android.media.AudioManager; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.SeekBar; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaArgs; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONException; + +public class VolumeSlider extends CordovaPlugin { + private SeekBar volumeSeekBar; + + private int cssToViewUnit(double size) { + return (int)Math.abs(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)size, + cordova.getActivity().getResources().getDisplayMetrics())); + } + + @Override + public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException { + if (action == null) + return false; + if (action.equals("createVolumeSlider")) { + final int x = cssToViewUnit(args.getDouble(0)); + final int y = cssToViewUnit(args.getDouble(1)); + final int width = cssToViewUnit(args.getDouble(2)); + final int height = cssToViewUnit(args.getDouble(3)); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + createVolumeSlider(x, y, width, height); + } + }); + return true; + } + if (action.equals("showVolumeSlider")) { + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + showVolumeSlider(); + } + }); + return true; + } + if (action.equals("hideVolumeSlider")) { + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + hideVolumeSlider(); + } + }); + return true; + } + return false; + } + + private void bindVolumeSeekBarToAudioManager(SeekBar volumeSeekBar, final Context context) + { + AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); + volumeSeekBar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)); + volumeSeekBar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)); + + volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0); + } + @Override + public void onStartTrackingTouch(SeekBar seekBar) {} + @Override + public void onStopTrackingTouch(SeekBar seekBar) {} + }); + } + + private void createVolumeSlider(int x, int y, int width, int height) { + RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); + params.leftMargin = x; + params.topMargin = y; + + Context context = cordova.getActivity(); + + volumeSeekBar = new SeekBar(context); + bindVolumeSeekBarToAudioManager(volumeSeekBar, context); + hideVolumeSlider(); + + RelativeLayout layout = new RelativeLayout(context); + layout.addView(volumeSeekBar, params); + ViewGroup container = (ViewGroup)cordova.getActivity().findViewById(android.R.id.content); + container.addView(layout); + } + + private void showVolumeSlider() { + volumeSeekBar.setVisibility(View.VISIBLE); + } + + private void hideVolumeSlider() { + volumeSeekBar.setVisibility(View.INVISIBLE); + } + +} From 433573e5a8d93afce9a267144944660fbe213ed5 Mon Sep 17 00:00:00 2001 From: Prayash Thapa Date: Thu, 11 Jun 2015 16:49:08 -0600 Subject: [PATCH 07/10] Additional functionality onCreate to record current_volume. Add setVolume and resetVolume methods. --- src/android/VolumeSlider.java | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/android/VolumeSlider.java b/src/android/VolumeSlider.java index 7eb90ea..3d88bfd 100755 --- a/src/android/VolumeSlider.java +++ b/src/android/VolumeSlider.java @@ -12,9 +12,13 @@ import org.apache.cordova.CordovaArgs; import org.apache.cordova.CordovaPlugin; import org.json.JSONException; +import android.util.Log; public class VolumeSlider extends CordovaPlugin { + int current_volume; private SeekBar volumeSeekBar; + private static final String TAG = "volume_slider"; + private AudioManager audioManager; private int cssToViewUnit(double size) { return (int)Math.abs(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)size, @@ -56,12 +60,31 @@ public void run() { }); return true; } + if (action.equals("setVolumeSlider")) { + final int vol = cssToViewUnit(args.getDouble(0)); + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + setVolumeSlider(vol); + } + }); + return true; + } + if (action.equals("resetVolumeSlider")) { + cordova.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + resetVolumeSlider(); + } + }); + return true; + } return false; } private void bindVolumeSeekBarToAudioManager(SeekBar volumeSeekBar, final Context context) { - AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); + audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); volumeSeekBar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)); volumeSeekBar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)); @@ -79,6 +102,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {} } private void createVolumeSlider(int x, int y, int width, int height) { + Log.d(TAG, "creating the slider" ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.leftMargin = x; params.topMargin = y; @@ -87,6 +111,10 @@ private void createVolumeSlider(int x, int y, int width, int height) { volumeSeekBar = new SeekBar(context); bindVolumeSeekBarToAudioManager(volumeSeekBar, context); + + current_volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); + Log.d(TAG, "current_volume=" + current_volume); hideVolumeSlider(); RelativeLayout layout = new RelativeLayout(context); @@ -103,4 +131,11 @@ private void hideVolumeSlider() { volumeSeekBar.setVisibility(View.INVISIBLE); } + private void setVolumeSlider(int volume) { + Log.d(TAG, "Setting the volume: " + volume ); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); + } + private void resetVolumeSlider() { + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); + } } From b059740602d2666b9b5bcc398cdc8a13b6dda88b Mon Sep 17 00:00:00 2001 From: Prayash Thapa Date: Fri, 12 Jun 2015 12:39:38 -0600 Subject: [PATCH 08/10] Clean up code + add comments. --- src/android/VolumeSlider.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/android/VolumeSlider.java b/src/android/VolumeSlider.java index 3d88bfd..78d278d 100755 --- a/src/android/VolumeSlider.java +++ b/src/android/VolumeSlider.java @@ -15,10 +15,10 @@ import android.util.Log; public class VolumeSlider extends CordovaPlugin { - int current_volume; private SeekBar volumeSeekBar; - private static final String TAG = "volume_slider"; private AudioManager audioManager; + private static final String TAG = "volume_slider"; + int current_volume = .2; private int cssToViewUnit(double size) { return (int)Math.abs(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)size, @@ -111,10 +111,11 @@ private void createVolumeSlider(int x, int y, int width, int height) { volumeSeekBar = new SeekBar(context); bindVolumeSeekBarToAudioManager(volumeSeekBar, context); - + + // Record current set media volume to revert to current_volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); - Log.d(TAG, "current_volume=" + current_volume); + Log.d(TAG, "current_volume = " + current_volume); hideVolumeSlider(); RelativeLayout layout = new RelativeLayout(context); @@ -133,9 +134,10 @@ private void hideVolumeSlider() { private void setVolumeSlider(int volume) { Log.d(TAG, "Setting the volume: " + volume ); - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume*audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); } private void resetVolumeSlider() { + // Revert back to initial volume audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); } } From 602fc9009b665b97c88c5761d5685f74fc80697b Mon Sep 17 00:00:00 2001 From: Prayash Thapa Date: Fri, 12 Jun 2015 16:21:14 -0600 Subject: [PATCH 09/10] Make additional changes so that it can be usable by others. --- src/android/VolumeSlider.java | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/android/VolumeSlider.java b/src/android/VolumeSlider.java index 78d278d..1545350 100755 --- a/src/android/VolumeSlider.java +++ b/src/android/VolumeSlider.java @@ -18,13 +18,18 @@ public class VolumeSlider extends CordovaPlugin { private SeekBar volumeSeekBar; private AudioManager audioManager; private static final String TAG = "volume_slider"; - int current_volume = .2; + double current_volume = 0.2; private int cssToViewUnit(double size) { return (int)Math.abs(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)size, cordova.getActivity().getResources().getDisplayMetrics())); } + private double cssToViewUnitDouble(double size) { + return TypedValue.applyDimension(TypedValue.TYPE_NULL, (float)size, + cordova.getActivity().getResources().getDisplayMetrics()); + } + @Override public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException { if (action == null) @@ -61,11 +66,12 @@ public void run() { return true; } if (action.equals("setVolumeSlider")) { - final int vol = cssToViewUnit(args.getDouble(0)); + final double volume = cssToViewUnitDouble(args.getDouble(0)); cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { - setVolumeSlider(vol); + Log.d(TAG, "DESIRED VOLUME: " + volume); + setVolumeSlider(volume); } }); return true; @@ -102,7 +108,6 @@ public void onStopTrackingTouch(SeekBar seekBar) {} } private void createVolumeSlider(int x, int y, int width, int height) { - Log.d(TAG, "creating the slider" ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.leftMargin = x; params.topMargin = y; @@ -112,10 +117,9 @@ private void createVolumeSlider(int x, int y, int width, int height) { volumeSeekBar = new SeekBar(context); bindVolumeSeekBarToAudioManager(volumeSeekBar, context); - // Record current set media volume to revert to + // Record current media volume to revert to with resetVolumeSlider() current_volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); - Log.d(TAG, "current_volume = " + current_volume); + Log.d(TAG, "CURRENT VOLUME = " + current_volume); hideVolumeSlider(); RelativeLayout layout = new RelativeLayout(context); @@ -132,12 +136,15 @@ private void hideVolumeSlider() { volumeSeekBar.setVisibility(View.INVISIBLE); } - private void setVolumeSlider(int volume) { - Log.d(TAG, "Setting the volume: " + volume ); - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume*audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); + private void setVolumeSlider(double volume) { + // We map volume to a range of 0.0 - 1.0 + Log.d(TAG, "SET VOLUME TO: " + (int)(volume * audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)(volume * audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)), 0); } + private void resetVolumeSlider() { - // Revert back to initial volume - audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, current_volume, 0); + // Resetting back to initial volume + Log.d(TAG, "RESET VOLUME TO: " + (int)(current_volume)); + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)(current_volume), 0); } -} +} \ No newline at end of file From e62c65cb8a6ca1f928f2d94fabb939542928b7ab Mon Sep 17 00:00:00 2001 From: Prayash Thapa Date: Fri, 12 Jun 2015 16:27:09 -0600 Subject: [PATCH 10/10] Clean up. --- src/android/VolumeSlider.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/android/VolumeSlider.java b/src/android/VolumeSlider.java index 1545350..32ff9dc 100755 --- a/src/android/VolumeSlider.java +++ b/src/android/VolumeSlider.java @@ -70,7 +70,6 @@ public void run() { cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { - Log.d(TAG, "DESIRED VOLUME: " + volume); setVolumeSlider(volume); } }); @@ -138,13 +137,13 @@ private void hideVolumeSlider() { private void setVolumeSlider(double volume) { // We map volume to a range of 0.0 - 1.0 - Log.d(TAG, "SET VOLUME TO: " + (int)(volume * audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))); + Log.d(TAG, "SET VOLUME TO: " + volume); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)(volume * audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)), 0); } private void resetVolumeSlider() { // Resetting back to initial volume - Log.d(TAG, "RESET VOLUME TO: " + (int)(current_volume)); + Log.d(TAG, "RESET VOLUME TO: " + current_volume); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)(current_volume), 0); } } \ No newline at end of file