Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 0a5a72df4 -> 4e36c0dc3


CB-11529 ios: Make available setting volume for player on ios device

 This closes #106


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/4e36c0dc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/4e36c0dc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/4e36c0dc

Branch: refs/heads/master
Commit: 4e36c0dc324ed63a786cdc7ecef5f545b9a6357a
Parents: 0a5a72d
Author: Nikita Matrosov <nikita.matro...@rp.ru>
Authored: Fri Aug 12 12:43:10 2016 +0300
Committer: Vladimir Kotikov <kotikov.vladi...@gmail.com>
Committed: Wed Sep 21 18:01:09 2016 +0300

----------------------------------------------------------------------
 src/ios/CDVSound.m |  9 +++++++++
 tests/tests.js     | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/4e36c0dc/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 09d3587..97f5d6e 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -270,6 +270,15 @@
             if (audioFile.player) {
                 audioFile.player.volume = [volume floatValue];
             }
+            else {
+                float customVolume = [volume floatValue];
+                if (customVolume >= 0.0 && customVolume <= 1.0) {
+                    [avPlayer setVolume: customVolume];
+                }
+                else {
+                    NSLog(@"The value must be within the range of 0.0 to 1.0");
+                }
+            }
             [[self soundCache] setObject:audioFile forKey:mediaId];
         }
     }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/4e36c0dc/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index fa283d9..9a27ced 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -709,6 +709,15 @@ exports.defineManualTests = function (contentEl, 
createActionButton) {
         });
     }
 
+    //set audio volume
+    function setVolume() {
+        console.log("setVolume()");
+        var volume = document.getElementById("volumeInput").value;
+        if (media1 !== null) {
+            media1.setVolume(volume);
+        }
+    }
+
     //for forced updates of position after a successful seek
 
     function updatePosition() {
@@ -970,6 +979,24 @@ exports.defineManualTests = function (contentEl, 
createActionButton) {
                 row:0,
                 cell:2
             }
+        },
+         {
+            id: "setVolumeBtn",
+            content: "",
+            tag: "div",
+            position: {
+                row: 3,
+                cell: 0
+            }
+        },
+        {
+            id: "volumeInput",
+            tag: "input",
+            type: "text",
+            position: {
+                row: 3,
+                cell: 1
+            }
         }
     ],
     elementsRecord =
@@ -1022,7 +1049,7 @@ exports.defineManualTests = function (contentEl, 
createActionButton) {
     div.setAttribute("align", "center");
     contentEl.appendChild(div);
     //Generate and add buttons table
-    contentEl.appendChild(generateTable('audioActions', 3, 3, elementsAudio));
+    contentEl.appendChild(generateTable('audioActions', 4, 3, elementsAudio));
     createActionButton('Play', function () {
         playAudio();
     }, 'playBtn');
@@ -1055,6 +1082,9 @@ exports.defineManualTests = function (contentEl, 
createActionButton) {
     createActionButton('Seek To', function () {
         seekAudio('to');
     }, 'seekToBtn');
+    createActionButton('Set volume', function() {
+        setVolume();
+    }, 'setVolumeBtn');
     //get Special path to record if iOS || Blackberry
     if (cordova.platformId === 'ios')
         getRecordSrc();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to