cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] cordova-plugin-media git commit: CB-9606 Fixes arguments parsing in `seekAudio`
Date Thu, 03 Sep 2015 21:29:25 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master c9ca8a63e -> 4321b3f07


CB-9606 Fixes arguments parsing in `seekAudio`


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

Branch: refs/heads/master
Commit: 9e137ccb4e60570cec09d405e5777f064354339e
Parents: c9ca8a6
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Thu Sep 3 13:30:19 2015 +0300
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Thu Sep 3 14:29:08 2015 -0700

----------------------------------------------------------------------
 src/wp/Media.cs |  4 ++--
 tests/tests.js  | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/9e137ccb/src/wp/Media.cs
----------------------------------------------------------------------
diff --git a/src/wp/Media.cs b/src/wp/Media.cs
index 72d818b..b0d85b2 100644
--- a/src/wp/Media.cs
+++ b/src/wp/Media.cs
@@ -460,11 +460,11 @@ namespace WPCordovaClassLib.Cordova.Commands
                     mediaOptions = new MediaOptions();
                     mediaOptions.Id = optionsString[0];
                     int msec = 0;
-                    if (int.TryParse(optionsString[2], out msec))
+                    if (int.TryParse(optionsString[1], out msec))
                     {
                         mediaOptions.Milliseconds = msec;
                     }
-                    callbackId = mediaOptions.CallbackId = optionsString[3];
+                    callbackId = mediaOptions.CallbackId = optionsString[2];
 
                 }
                 catch (Exception)

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/9e137ccb/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 068d604..bbf7c1e 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -295,6 +295,34 @@ exports.defineAutoTests = function () {
                 media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange);
                 media.play();
             }, ACTUAL_PLAYBACK_TEST_TIMEOUT);
+
+            it("media.spec.21 should be able to seek through file", function (done) {
+                if (!isAudioSupported || cordova.platformId === 'blackberry10') {
+                    pending();
+                }
+
+                //context variable used as an extra security statement to ensure that the
callback is processed only once,
+                //in case the statusChange callback is reached more than one time with the
same status code.
+                //Some information about this kind of behaviour can be found at JIRA: CB-7099.
+                var context = this;
+                var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3';
+                var successCallback = function () { };
+                var statusChange = function (statusCode) {
+                    if (!context.done && statusCode == Media.MEDIA_RUNNING) {
+                        checkInterval = setInterval(function () {
+                            if (context.done) return;
+                            media.seekTo(5000);
+                            media.getCurrentPosition(function (position) {
+                                expect(position).toBe(5);
+                                context.done = true;
+                                done();
+                            }, failed.bind(null, done, 'media1.getCurrentPosition - Error
getting media current position', context));
+                        }, 1000);
+                    }
+                };
+                media = new Media(mediaFile, successCallback, failed.bind(self, done, 'media1
= new Media - Error creating Media object. Media file: ' + mediaFile, context), statusChange);
+                media.play();
+            }, ACTUAL_PLAYBACK_TEST_TIMEOUT);
         });
 
         it("media.spec.18 should contain a setRate function", function () {


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


Mime
View raw message