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 2014/09/27 00:44:48 UTC
git commit: CB-7638 Get audio duration properly on windows
Repository: cordova-plugin-media
Updated Branches:
refs/heads/master 526a73853 -> 2660e925a
CB-7638 Get audio duration properly on windows
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/2660e925
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/2660e925
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/2660e925
Branch: refs/heads/master
Commit: 2660e925ab3a4926999333751819fdac017698f7
Parents: 526a738
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Sep 25 10:36:02 2014 +0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Sep 25 15:40:35 2014 +0400
----------------------------------------------------------------------
src/windows8/MediaProxy.js | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/2660e925/src/windows8/MediaProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/MediaProxy.js b/src/windows8/MediaProxy.js
index dc00c79..bf225f8 100644
--- a/src/windows8/MediaProxy.js
+++ b/src/windows8/MediaProxy.js
@@ -47,11 +47,17 @@ module.exports = {
fn === 'm3u' || fn === 'wmx' || fn === 'm4a') {
thisM.node = new Audio(src);
thisM.node.load();
- var dur = thisM.node.duration;
- if (isNaN(dur)) {
- dur = -1;
- }
- Media.onStatus(id, Media.MEDIA_DURATION, dur);
+
+ var getDuration = function () {
+ var dur = thisM.node.duration;
+ if (isNaN(dur)) {
+ dur = -1;
+ }
+ Media.onStatus(id, Media.MEDIA_DURATION, dur);
+ };
+
+ thisM.node.onloadedmetadata = getDuration;
+ getDuration();
}
else {
lose && lose({code:MediaError.MEDIA_ERR_ABORTED});