You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2015/02/11 16:34:28 UTC

cordova-plugin-media git commit: CB-8428 Fix tests on Windows if no audio playback hardware is available

Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master fb45b2a01 -> bcf17ef98


CB-8428 Fix tests on Windows if no audio playback hardware is available


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/bcf17ef9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/bcf17ef9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/bcf17ef9

Branch: refs/heads/master
Commit: bcf17ef98597fb55e856852ba91fc5e210f8a1f3
Parents: fb45b2a
Author: sgrebnov <v-...@microsoft.com>
Authored: Wed Feb 11 18:34:45 2015 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Wed Feb 11 18:34:45 2015 +0300

----------------------------------------------------------------------
 src/windows/MediaProxy.js |  8 ++++++--
 tests/tests.js            | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/bcf17ef9/src/windows/MediaProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/MediaProxy.js b/src/windows/MediaProxy.js
index a76c800..cb1457b 100644
--- a/src/windows/MediaProxy.js
+++ b/src/windows/MediaProxy.js
@@ -96,8 +96,12 @@ module.exports = {
     stopPlayingAudio:function(win, lose, args) {
         var id = args[0];
         try {
-            (Media.get(id)).node.pause();
-            (Media.get(id)).node.currentTime = 0;
+            var thisM = Media.get(id);
+            thisM.node.pause();
+            if (thisM.node.currentTime != 0) {
+                // prevents failing w/ InvalidStateError if playback has not started
+                thisM.node.currentTime = 0;
+            }
             Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
             win();
         } catch (err) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/bcf17ef9/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index ea8826d..b18535d 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -18,6 +18,10 @@
  * under the License.
  *
  */
+ 
+var isWindows = cordova.platformId == 'windows8' || cordova.platformId == 'windows';
+// detect whether audio hardware is available and enabled
+var isAudioSupported = isWindows ? Windows.Media.Devices.MediaDevice.getDefaultAudioRenderId(Windows.Media.Devices.AudioDeviceRole.default) : true;
 
 exports.defineAutoTests = function () {
     var failed = function (done, msg, error) {
@@ -180,6 +184,11 @@ exports.defineAutoTests = function () {
         });
 
         it("media.spec.16 position should be set properly", function (done) {
+            // no audio hardware available
+            if (!isAudioSupported) {
+                pending();
+                return;
+            }
             var self = this;
             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
             mediaState = Media.MEDIA_STOPPED,
@@ -208,6 +217,11 @@ exports.defineAutoTests = function () {
         });
 
         it("media.spec.17 duration should be set properly", function (done) {
+            // no audio hardware available
+            if (!isAudioSupported) {
+                pending();
+                return;
+            }
             var self = this;
             if (cordova.platformId === 'blackberry10') {
                 expect(true).toFailWithMessage('Platform does not supported this feature');


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