cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject [1/2] cordova-plugin-media git commit: CB-11430 Report duration NaN value to JS properly
Date Thu, 23 Jun 2016 07:06:28 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 6877c78d6 -> 17fc9f3dd


CB-11430 Report duration NaN value to JS properly

This closes #102


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

Branch: refs/heads/master
Commit: cd185eaa4f020abbc6dbcd8dcc3ce63c54a6b868
Parents: 6877c78
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Fri Jun 17 16:53:29 2016 +0300
Committer: Vladimir Kotikov <kotikov.vladimir@gmail.com>
Committed: Thu Jun 23 10:04:52 2016 +0300

----------------------------------------------------------------------
 src/ios/CDVSound.m | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/cd185eaa/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 1a78288..92d5f91 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -342,12 +342,13 @@
             }
             if (!bError) {
                 NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
-                double position = 0;
+                double duration = 0;
                 if (avPlayer.currentItem && avPlayer.currentItem.asset) {
                     CMTime time = avPlayer.currentItem.asset.duration;
-                    position = CMTimeGetSeconds(time);
-                    if (isnan(position)) {
-                        position = 0;
+                    duration = CMTimeGetSeconds(time);
+                    if (isnan(duration)) {
+                        NSLog(@"Duration is infifnite, setting it to -1");
+                        duration = -1;
                     }
 
                     if (audioFile.rate != nil){
@@ -355,7 +356,7 @@
                         NSLog(@"Playing stream with AVPlayer & custom rate");
                         [avPlayer setRate:customRate];
                     } else {
-                        NSLog(@"Playing stream with AVPlayer & custom rate");
+                        NSLog(@"Playing stream with AVPlayer & default rate");
                         [avPlayer play];
                     }
 
@@ -381,10 +382,10 @@
                     }
 
                     [audioFile.player play];
-                    position = round(audioFile.player.duration * 1000) / 1000;
+                    duration = round(audioFile.player.duration * 1000) / 1000;
                 }
 
-                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];
+                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);",
@"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_DURATION, duration,
@"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
                 [self.commandDelegate evalJs:jsString];
             }
         }


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


Mime
View raw message