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 2016/01/30 00:48:05 UTC

[03/13] cordova-plugin-media git commit: fix getDuration() returns 0

fix getDuration() returns 0


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

Branch: refs/heads/master
Commit: 31d53623b4b0cb8b5f7cd738334ac2098a864db3
Parents: db918c1
Author: ghenry22 <gh...@gmail.com>
Authored: Tue Oct 13 08:40:27 2015 +0800
Committer: ghenry22 <gh...@gmail.com>
Committed: Tue Oct 13 08:40:27 2015 +0800

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/31d53623/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 93adf42..50b15ee 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -337,8 +337,8 @@
             if (!bError) {
                 NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
                 double position = 0;
-                if (avPlayer) {
-                    CMTime time = [avPlayer currentTime];
+                if (avPlayer.currentItem && avPlayer.currentItem.asset) {
+                    CMTime time = avPlayer.currentItem.asset.duration;
                     position = CMTimeGetSeconds(time);
                     NSLog(@"Playing stream with AVPlayer");
                     [avPlayer play];
@@ -364,7 +364,7 @@
                     }
 
                     [audioFile.player play];
-                    //double position = round(audioFile.player.duration * 1000) / 1000;
+                    position = 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];


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