Updated MediaProxy and MediaFileProxy
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/1b0e0295 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/1b0e0295 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/1b0e0295 Branch: refs/heads/master Commit: 1b0e02959be8db15e3939bfb2e2ae75b8bd56c16 Parents: 5f5c576 Author: mpberk <matthew.p.b...@intel.com> Authored: Wed Aug 15 10:41:56 2012 -0700 Committer: mpberk <matthew.p.b...@intel.com> Committed: Wed Aug 15 10:41:56 2012 -0700 ---------------------------------------------------------------------- lib/win8metro/plugin/win8metro/MediaFileProxy.js | 2 +- lib/win8metro/plugin/win8metro/MediaProxy.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/1b0e0295/lib/win8metro/plugin/win8metro/MediaFileProxy.js ---------------------------------------------------------------------- diff --git a/lib/win8metro/plugin/win8metro/MediaFileProxy.js b/lib/win8metro/plugin/win8metro/MediaFileProxy.js index 45c486b..e9c4e72 100755 --- a/lib/win8metro/plugin/win8metro/MediaFileProxy.js +++ b/lib/win8metro/plugin/win8metro/MediaFileProxy.js @@ -1,4 +1,4 @@ -var utils = require('cordova/utils'), +var utils = require('cordova/utils'), File = require('cordova/plugin/File'), CaptureError = require('cordova/plugin/CaptureError'); /** http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/1b0e0295/lib/win8metro/plugin/win8metro/MediaProxy.js ---------------------------------------------------------------------- diff --git a/lib/win8metro/plugin/win8metro/MediaProxy.js b/lib/win8metro/plugin/win8metro/MediaProxy.js index 515b0f3..0667684 100644 --- a/lib/win8metro/plugin/win8metro/MediaProxy.js +++ b/lib/win8metro/plugin/win8metro/MediaProxy.js @@ -7,15 +7,22 @@ module.exports = { create:function(win, lose, args) { var id = args[0]; var src = args[1]; + var thisM = Media.get(id); + Media.prototype.node = null; var fn = src.split('.').pop(); // gets the file extension - if ((Media.get(id)).node === null) { + if (thisM.node === null) { if (fn === 'mp3' || fn === 'wma' || fn === 'wma' || fn === 'cda' || fn === 'adx' || fn === 'wm' || fn === 'm3u' || fn === 'wmx') { - (Media.get(id)).node = new Audio(src); - (Media.get(id)).node.load(); + 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); } else { lose("Invalid file type"); } @@ -36,6 +43,7 @@ module.exports = { try { (Media.get(id)).node.pause(); (Media.get(id)).node.currentTime = 0; + Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); win(); } catch (err) { lose("Failed to stop: "+err); @@ -69,6 +77,7 @@ module.exports = { var id = args[0]; try { var p = (Media.get(id)).node.currentTime; + Media.onStatus(id, Media.MEDIA_POSITION, p); win(p); } catch (err) { lose(err);