You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/07/10 21:20:06 UTC

[1/9] cordova-plugin-media git commit: Add Media.prototype.setRate method (only for iOS)

Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 96b0a8485 -> 9175d5d32


Add Media.prototype.setRate method (only for iOS)


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

Branch: refs/heads/master
Commit: c41a40dd05516ebe2f514dacd31c1f6090ada815
Parents: ab6563a
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Sat Jan 3 04:54:25 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Sat Jan 3 04:54:25 2015 +0500

----------------------------------------------------------------------
 src/ios/CDVSound.h |  3 +++
 src/ios/CDVSound.m | 29 +++++++++++++++++++++++++++++
 www/Media.js       |  8 ++++++++
 3 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c41a40dd/src/ios/CDVSound.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.h b/src/ios/CDVSound.h
index 984924d..21ee06b 100644
--- a/src/ios/CDVSound.h
+++ b/src/ios/CDVSound.h
@@ -69,12 +69,14 @@ typedef NSUInteger CDVMediaMsg;
     CDVAudioPlayer* player;
     CDVAudioRecorder* recorder;
     NSNumber* volume;
+    NSNumber* rate;
 }
 
 @property (nonatomic, strong) NSString* resourcePath;
 @property (nonatomic, strong) NSURL* resourceURL;
 @property (nonatomic, strong) CDVAudioPlayer* player;
 @property (nonatomic, strong) NSNumber* volume;
+@property (nonatomic, strong) NSNumber* rate;
 
 @property (nonatomic, strong) CDVAudioRecorder* recorder;
 
@@ -109,5 +111,6 @@ typedef NSUInteger CDVMediaMsg;
 - (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command;
 
 - (void)setVolume:(CDVInvokedUrlCommand*)command;
+- (void)setRate:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c41a40dd/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 8ceaf5b..de9ca19 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -251,6 +251,29 @@
     // don't care for any callbacks
 }
 
+- (void)setRate:(CDVInvokedUrlCommand*)command
+{
+    NSString* callbackId = command.callbackId;
+
+#pragma unused(callbackId)
+    NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSNumber* rate = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
+
+    if ([self soundCache] != nil) {
+        CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
+        if (audioFile != nil) {
+            audioFile.rate = rate;
+            if (audioFile.player) {
+                audioFile.player.enableRate = YES;
+                audioFile.player.rate = [rate floatValue];
+            }
+            [[self soundCache] setObject:audioFile forKey:mediaId];
+        }
+    }
+
+    // don't care for any callbacks
+}
+
 - (void)startPlayingAudio:(CDVInvokedUrlCommand*)command
 {
     NSString* callbackId = command.callbackId;
@@ -303,6 +326,11 @@
                     audioFile.player.volume = [audioFile.volume floatValue];
                 }
 
+                if (audioFile.rate != nil) {
+                    audioFile.player.enableRate = YES
+                    audioFile.player.rate = [audioFile.rate floatValue];
+                }
+
                 [audioFile.player play];
                 double position = round(audioFile.player.duration * 1000) / 1000;
                 jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
@@ -686,6 +714,7 @@
 @synthesize resourcePath;
 @synthesize resourceURL;
 @synthesize player, volume;
+@synthesize player, rate;
 @synthesize recorder;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c41a40dd/www/Media.js
----------------------------------------------------------------------
diff --git a/www/Media.js b/www/Media.js
index 083af36..3fb4db7 100644
--- a/www/Media.js
+++ b/www/Media.js
@@ -153,6 +153,14 @@ Media.prototype.setVolume = function(volume) {
 };
 
 /**
+ * Adjust the playback rate.
+ */
+Media.prototype.setRate = function(rate) {
+    exec(null, null, "Media", "setRate", [this.id, rate]);
+};
+
+
+/**
  * Audio has status update.
  * PRIVATE
  *


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


[8/9] cordova-plugin-media git commit: rate is enabled, otherwise media has to be stopped and started to change rate. Fixed error getting command args

Posted by pu...@apache.org.
rate is enabled, otherwise media has to be stopped and started to change rate. Fixed error getting command args


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

Branch: refs/heads/master
Commit: 66d0f27f741baa1be7a192354994cddc0d28d17a
Parents: 072656d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jul 10 12:18:44 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jul 10 12:18:44 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVSound.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/66d0f27f/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index af63a48..a23111f 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -256,8 +256,8 @@
     NSString* callbackId = command.callbackId;
 
 #pragma unused(callbackId)
-    NSString* mediaId = [command.arguments objectAtIndex:0];
-    NSNumber* rate = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
+    NSString* mediaId = [command argumentAtIndex:0];
+    NSNumber* rate = [command argumentAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
 
     if ([self soundCache] != nil) {
         CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
@@ -326,8 +326,8 @@
                     audioFile.player.volume = [audioFile.volume floatValue];
                 }
 
+                audioFile.player.enableRate = YES;
                 if (audioFile.rate != nil) {
-                    audioFile.player.enableRate = YES
                     audioFile.player.rate = [audioFile.rate floatValue];
                 }
 


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


[4/9] cordova-plugin-media git commit: Added iOS platform media.setRate auto test

Posted by pu...@apache.org.
Added iOS platform media.setRate auto test


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

Branch: refs/heads/master
Commit: b003c5bca9b5db0d9a38daaf6a52a9d891ac115b
Parents: 36e5419
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Fri Jan 23 08:33:40 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Fri Jan 23 08:33:40 2015 +0500

----------------------------------------------------------------------
 tests/tests.js | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/b003c5bc/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 3e8ad9f..cf8b3a6 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -229,6 +229,45 @@ exports.defineAutoTests = function () {
             media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
             media1.play();
         });
+
+        it("media.spec.18 should contain a setRate function", function () {
+            var media1 = new Media();
+            expect(media1.setRate).toBeDefined();
+            expect(typeof media1.setRate).toBe('function');
+            media1.release();
+        });
+
+        it("media.spec.19 playback rate should be set properly using setRate", function (done) {
+            if (cordova.platformId !== 'ios') {
+                expect(true).toFailWithMessage('Platform does not supported this feature');
+                done();
+            }
+            var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
+                mediaState = Media.MEDIA_STOPPED,
+                successCallback,
+                flag = true,
+                statusChange = function (statusCode) {
+                    if (statusCode == Media.MEDIA_RUNNING && flag) {
+                        //flag variable used to ensure an extra security statement to ensure that the callback is processed only once,
+                        //in case for some reason the statusChange callback is reached more than one time with the same status code.
+                        //Some information about this kind of behavior it can be found at JIRA: CB-7099
+                        flag = false;
+                        setTimeout(function () {
+                            media1.getCurrentPosition(function (position) {
+                                //in four seconds expect position to be two times greater with some degree (1 sec) of accuracy
+                                expect(position).toBeGreaterThan(7);
+                                media1.stop();
+                                media1.release();
+                                done();
+                            }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting media current position'));
+                        }, 4000);
+                    }
+                },
+                media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
+            //make audio playback two times faster
+            media1.setRate(2);
+            media1.play();
+        });
     });
 };
 


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


[3/9] cordova-plugin-media git commit: Add iOS platform check in Media.prototype.setRate fix

Posted by pu...@apache.org.
Add iOS platform check in Media.prototype.setRate fix


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

Branch: refs/heads/master
Commit: 36e541971f1ee3ae6105d5616b2e85e56a6676ae
Parents: d9240dc
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Fri Jan 16 05:05:03 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Fri Jan 16 05:05:03 2015 +0500

----------------------------------------------------------------------
 www/Media.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/36e54197/www/Media.js
----------------------------------------------------------------------
diff --git a/www/Media.js b/www/Media.js
index 16a513f..2ba5952 100644
--- a/www/Media.js
+++ b/www/Media.js
@@ -149,18 +149,18 @@ Media.prototype.release = function() {
  * Adjust the volume.
  */
 Media.prototype.setVolume = function(volume) {
-    if (device.platform == 'iOS'){
-        exec(null, null, "Media", "setVolume", [this.id, volume]);
-    } else {
-        console.warn('media.setRate method is currently not supported for', device.platform, 'platform.')
-    }
+    exec(null, null, "Media", "setVolume", [this.id, volume]);
 };
 
 /**
  * Adjust the playback rate.
  */
 Media.prototype.setRate = function(rate) {
-    exec(null, null, "Media", "setRate", [this.id, rate]);
+    if (cordova.platformId === 'ios'){
+        exec(null, null, "Media", "setRate", [this.id, rate]);
+    } else {
+        console.warn('media.setRate method is currently not supported for', cordova.platformId, 'platform.')
+    }
 };
 
 


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


[9/9] cordova-plugin-media git commit: resolved conflicts, added manual test button to change audio playback rate.

Posted by pu...@apache.org.
resolved conflicts, added manual test button to change audio playback rate.


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

Branch: refs/heads/master
Commit: 9175d5d322d6e603a4c8531a197d3f0d67fa50d0
Parents: 66d0f27
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jul 10 12:19:37 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jul 10 12:19:37 2015 -0700

----------------------------------------------------------------------
 tests/tests.js | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/9175d5d3/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 0e98b72..a2b427f 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -199,35 +199,10 @@ exports.defineAutoTests = function () {
                 }
             });
 
-<<<<<<< HEAD
             it("media.spec.16 position should be set properly", function (done) {
                 // no audio hardware available
                 if (!isAudioSupported) {
                     pending();
-=======
-        it("media.spec.17 duration should be set properly", function (done) {
-            if (cordova.platformId === 'blackberry10') {
-                expect(true).toFailWithMessage('Platform does not supported this feature');
-                done();
-                return
-            }
-            var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
-            mediaState = Media.MEDIA_STOPPED,
-            successCallback,
-            flag = true,
-            statusChange = function (statusCode) {
-                if (statusCode == Media.MEDIA_RUNNING && flag) {
-                    //flag variable used to ensure an extra security statement to ensure that the callback is processed only once,
-                    //in case for some reason the statusChange callback is reached more than one time with the same status code.
-                    //Some information about this kind of behavior it can be found at JIRA: CB-7099.
-                    flag = false;
-                    setTimeout(function () {
-                        expect(media1.getDuration()).toBeGreaterThan(0.0);
-                        media1.stop();
-                        media1.release();
-                        done();
-                    }, 1000);
->>>>>>> 062221e90883db49da05ad75f322ccea33433468
                 }
 
                 //context variable used as an extra security statement to ensure that the callback is processed only once,
@@ -294,8 +269,8 @@ exports.defineAutoTests = function () {
         it("media.spec.19 playback rate should be set properly using setRate", function (done) {
             if (cordova.platformId !== 'ios') {
                 expect(true).toFailWithMessage('Platform does not supported this feature');
-                done();
-                return
+                pending();
+                return;
             }
             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
                 mediaState = Media.MEDIA_STOPPED,
@@ -545,7 +520,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     function recordAudio() {
         console.log("recordAudio()");
         console.log(" -- media=" + mediaRec);
-        if (mediaRec == null) {
+        if (!mediaRec) {
             var src = recordSrc;
             mediaRec = new Media(src,
                     function () {
@@ -776,6 +751,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
                 row : 2,
                 cell : 2
             }
+        }, {
+            id: "halfSpeedBtn",
+            content:"",
+            tag:"div",
+            position:{
+                row:0,
+                cell:2
+            }
         }
     ],
     elementsRecord =
@@ -835,6 +818,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
     createActionButton('Pause', function () {
         pauseAudio();
     }, 'pauseBtn');
+    createActionButton('HalfSpeed', function() {
+    
+        if(halfSpeedBtn.firstChild.firstChild.innerText == 'HalfSpeed') {
+            halfSpeedBtn.firstChild.firstChild.innerText = 'FullSpeed';
+            media1.setRate(0.5);
+        }
+        else if(halfSpeedBtn.firstChild.firstChild.innerText == 'FullSpeed') {
+            halfSpeedBtn.firstChild.firstChild.innerText = 'DoubleSpeed';
+            media1.setRate(1.0);
+        }
+        else {
+            halfSpeedBtn.firstChild.firstChild.innerText = 'HalfSpeed';
+            media1.setRate(2.0);
+        }
+    }, 'halfSpeedBtn');
     createActionButton('Stop', function () {
         stopAudio();
     }, 'stopBtn');


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


[7/9] cordova-plugin-media git commit: fix conflict

Posted by pu...@apache.org.
fix conflict


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

Branch: refs/heads/master
Commit: 072656de2a12e6e8deb94ce8ce3fad9eb9ce42a3
Parents: 96b0a84 062221e
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Jul 10 11:03:25 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Jul 10 11:03:25 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVSound.h |  3 +++
 src/ios/CDVSound.m | 30 ++++++++++++++++++++++-
 tests/tests.js     | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
 www/Media.js       | 12 +++++++++
 4 files changed, 109 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/072656de/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --cc src/ios/CDVSound.m
index c104c9c,8300276..af63a48
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@@ -303,9 -326,14 +326,14 @@@
                      audioFile.player.volume = [audioFile.volume floatValue];
                  }
  
+                 if (audioFile.rate != nil) {
+                     audioFile.player.enableRate = YES
+                     audioFile.player.rate = [audioFile.rate floatValue];
+                 }
+ 
                  [audioFile.player play];
                  double position = round(audioFile.player.duration * 1000) / 1000;
 -                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
 +                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
                  [self.commandDelegate evalJs:jsString];
              }
          }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/072656de/tests/tests.js
----------------------------------------------------------------------
diff --cc tests/tests.js
index c960991,3fae18b..0e98b72
--- a/tests/tests.js
+++ b/tests/tests.js
@@@ -165,99 -154,122 +165,164 @@@ exports.defineAutoTests = function () 
          });
  
          it("media.spec.15 should return MediaError for bad filename", function (done) {
 -            var fileName = 'invalid.file.name';
 -            //Error callback it has an unexpected behavior under Windows Phone,
 -            //it enters to the error callback several times, instead of just one walk-through
 -            //JIRA issue related with all details: CB-7092
 -            //the conditional statement should be removed once the issue is fixed.
 -
              //bb10 dialog pops up, preventing tests from running
 -            if (cordova.platformId === 'blackberry10' || cordova.platformId === 'windowsphone') {
 -                expect(true).toFailWithMessage('Platform does not support this feature');
 -                done();
 -            } else {
 -                var badMedia = null;
 -                badMedia = new Media(fileName, succeed.bind(null, done, ' badMedia = new Media , Unexpected succees callback, it should not create Media object with invalid file name'), function (result) {
 -                        expect(result).toBeDefined();
 -                        expect(result.code).toBe(MediaError.MEDIA_ERR_ABORTED);
 -                        if (badMedia !== null) {
 -                            badMedia.release();
 -                        }
 -                        done();
 -                    });
 -                badMedia.play();
 +            if (cordova.platformId === 'blackberry10') {
 +                pending();
              }
 +
 +            var context = this,
 +                fileName = 'invalid.file.name',
 +                badMedia = new Media(fileName, succeed.bind(null, done, ' badMedia = new Media , Unexpected succees callback, it should not create Media object with invalid file name'), function (result) {
 +                    if (context.done) return;
 +                    context.done = true;
 +
 +                    expect(result).toBeDefined();
 +                    expect(result.code).toBe(MediaError.MEDIA_ERR_ABORTED);
 +                    if (badMedia) {
 +                        badMedia.release();
 +                    }
 +                    done();
 +                });
 +            badMedia.play();
          });
  
 -        it("media.spec.16 position should be set properly", function (done) {
 -            var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
 -            mediaState = Media.MEDIA_STOPPED,
 -            successCallback,
 -            flag = true,
 -            statusChange = function (statusCode) {
 -                if (statusCode == Media.MEDIA_RUNNING && flag) {
 -                    //flag variable used to ensure an extra security statement to ensure that the callback is processed only once,
 -                    //in case for some reason the statusChange callback is reached more than one time with the same status code.
 -                    //Some information about this kind of behavior it can be found at JIRA: CB-7099
 -                    flag = false;
 -                    setTimeout(function () {
 -                        media1.getCurrentPosition(function (position) {
 -                            expect(position).toBeGreaterThan(0.0);
 -                            media1.stop();
 -                            media1.release();
 -                            done();
 -                        }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting media current position'));
 -                    }, 1000);
 +        describe('actual playback', function() {
 +            var checkInterval,
 +                media;
 +
 +            afterEach(function() {
 +                clearInterval(checkInterval);
 +                if (media) {
 +                    media.stop();
 +                    media.release();
 +                    media = null;
                  }
 -            },
 -            media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
 -            media1.play();
 -        });
 +            });
  
++<<<<<<< HEAD
 +            it("media.spec.16 position should be set properly", function (done) {
 +                // no audio hardware available
 +                if (!isAudioSupported) {
 +                    pending();
++=======
+         it("media.spec.17 duration should be set properly", function (done) {
+             if (cordova.platformId === 'blackberry10') {
+                 expect(true).toFailWithMessage('Platform does not supported this feature');
+                 done();
+                 return
+             }
+             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
+             mediaState = Media.MEDIA_STOPPED,
+             successCallback,
+             flag = true,
+             statusChange = function (statusCode) {
+                 if (statusCode == Media.MEDIA_RUNNING && flag) {
+                     //flag variable used to ensure an extra security statement to ensure that the callback is processed only once,
+                     //in case for some reason the statusChange callback is reached more than one time with the same status code.
+                     //Some information about this kind of behavior it can be found at JIRA: CB-7099.
+                     flag = false;
+                     setTimeout(function () {
+                         expect(media1.getDuration()).toBeGreaterThan(0.0);
+                         media1.stop();
+                         media1.release();
+                         done();
+                     }, 1000);
++>>>>>>> 062221e90883db49da05ad75f322ccea33433468
                  }
 -            },
 -            media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
 -            media1.play();
 +
 +                //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,
 +                    mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
 +                    successCallback = function () { },
 +                    statusChange = function (statusCode) {
 +                        if (!context.done && statusCode == Media.MEDIA_RUNNING) {
 +                            checkInterval = setInterval(function () {
 +                                if (context.done) return;
 +                                media.getCurrentPosition(function successCallback(position) {
 +                                    if (position > 0.0) {
 +                                        context.done = true;
 +                                        expect(true).toBe(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.17 duration should be set properly", 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,
 +                    mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
 +                    successCallback = function () { },
 +                    statusChange = function (statusCode) {
 +                        if (!context.done && statusCode == Media.MEDIA_RUNNING) {
 +                            checkInterval = setInterval(function () {
 +                                if (context.done) return;
 +                                media.getCurrentPosition(function (position) {
 +                                    if (position > 0.0) {
 +                                        context.done = true;
 +                                        expect(media.getDuration()).toBeGreaterThan(0.0);
 +                                        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 () {
+             var media1 = new Media();
+             expect(media1.setRate).toBeDefined();
+             expect(typeof media1.setRate).toBe('function');
+             media1.release();
+         });
+ 
+         it("media.spec.19 playback rate should be set properly using setRate", function (done) {
+             if (cordova.platformId !== 'ios') {
+                 expect(true).toFailWithMessage('Platform does not supported this feature');
+                 done();
+                 return
+             }
+             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
+                 mediaState = Media.MEDIA_STOPPED,
+                 successCallback,
+                 flag = true,
+                 statusChange = function (statusCode) {
+                     if (statusCode == Media.MEDIA_RUNNING && flag) {
+                         //flag variable used to ensure an extra security statement to ensure that the callback is processed only once,
+                         //in case for some reason the statusChange callback is reached more than one time with the same status code.
+                         //Some information about this kind of behavior it can be found at JIRA: CB-7099
+                         flag = false;
+                         setTimeout(function () {
+                             media1.getCurrentPosition(function (position) {
+                                 //in four seconds expect position to be two times greater with some degree (1 sec) of accuracy
+                                 expect(position).toBeGreaterThan(7);
+                                 media1.stop();
+                                 media1.release();
+                                 done();
+                             }, failed.bind(null, done, 'media1.getCurrentPosition - Error getting media current position'));
+                         }, 4000);
+                     }
+                 },
+                 media1 = new Media(mediaFile, successCallback, failed.bind(null, done, 'media1 = new Media - Error creating Media object. Media file: ' + mediaFile), statusChange);
+             //make audio playback two times faster
+             media1.setRate(2);
+             media1.play();
+         });
      });
  };
  

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/072656de/www/Media.js
----------------------------------------------------------------------


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


[6/9] cordova-plugin-media git commit: Fix for @synthesize rate mistype

Posted by pu...@apache.org.
Fix for @synthesize rate mistype


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

Branch: refs/heads/master
Commit: 062221e90883db49da05ad75f322ccea33433468
Parents: 8c51597
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Sat Feb 7 00:49:33 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Sat Feb 7 00:49:33 2015 +0500

----------------------------------------------------------------------
 src/ios/CDVSound.m | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/062221e9/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index de9ca19..8300276 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -713,8 +713,7 @@
 
 @synthesize resourcePath;
 @synthesize resourceURL;
-@synthesize player, volume;
-@synthesize player, rate;
+@synthesize player, volume, rate;
 @synthesize recorder;
 
 @end


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


[5/9] cordova-plugin-media git commit: Added media.setRate auto test fix

Posted by pu...@apache.org.
Added media.setRate auto test fix


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

Branch: refs/heads/master
Commit: 8c5159727700a6185c39a6c54b75a8cfc7f16a0f
Parents: b003c5b
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Fri Jan 23 08:57:37 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Fri Jan 23 08:57:37 2015 +0500

----------------------------------------------------------------------
 tests/tests.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/8c515972/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index cf8b3a6..3fae18b 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -207,6 +207,7 @@ exports.defineAutoTests = function () {
             if (cordova.platformId === 'blackberry10') {
                 expect(true).toFailWithMessage('Platform does not supported this feature');
                 done();
+                return
             }
             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
             mediaState = Media.MEDIA_STOPPED,
@@ -241,6 +242,7 @@ exports.defineAutoTests = function () {
             if (cordova.platformId !== 'ios') {
                 expect(true).toFailWithMessage('Platform does not supported this feature');
                 done();
+                return
             }
             var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
                 mediaState = Media.MEDIA_STOPPED,


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


[2/9] cordova-plugin-media git commit: Add iOS platform check in Media.prototype.setRate

Posted by pu...@apache.org.
Add iOS platform check in Media.prototype.setRate


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

Branch: refs/heads/master
Commit: d9240dce05703982f9a49c0bbcbfbf7af46c6778
Parents: c41a40d
Author: Alex Oshchepkov <al...@gmail.com>
Authored: Wed Jan 7 01:32:31 2015 +0500
Committer: Alex Oshchepkov <al...@gmail.com>
Committed: Wed Jan 7 01:32:31 2015 +0500

----------------------------------------------------------------------
 www/Media.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/d9240dce/www/Media.js
----------------------------------------------------------------------
diff --git a/www/Media.js b/www/Media.js
index 3fb4db7..16a513f 100644
--- a/www/Media.js
+++ b/www/Media.js
@@ -149,7 +149,11 @@ Media.prototype.release = function() {
  * Adjust the volume.
  */
 Media.prototype.setVolume = function(volume) {
-    exec(null, null, "Media", "setVolume", [this.id, volume]);
+    if (device.platform == 'iOS'){
+        exec(null, null, "Media", "setVolume", [this.id, volume]);
+    } else {
+        console.warn('media.setRate method is currently not supported for', device.platform, 'platform.')
+    }
 };
 
 /**


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