You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/02/28 17:06:24 UTC
git commit: Fixing Media.play()
Updated Branches:
refs/heads/master 40e314e70 -> 4d625fe66
Fixing Media.play()
The Media constructor referenced a positionCallback which is not part of the constructor parameters so I removed it. Additionally the Media.onStatus() method was missing so I added it back in. Without this method the Media status and duration would never get updated.
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/4d625fe6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/4d625fe6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/4d625fe6
Branch: refs/heads/master
Commit: 4d625fe66d9cd129dd492e11998b3d1491b3738a
Parents: 40e314e
Author: macdonst <si...@gmail.com>
Authored: Tue Feb 28 11:04:59 2012 -0500
Committer: macdonst <si...@gmail.com>
Committed: Tue Feb 28 11:05:04 2012 -0500
----------------------------------------------------------------------
lib/plugin/Media.js | 40 ++++++++++++++++++++++++++++++++++------
1 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/4d625fe6/lib/plugin/Media.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Media.js b/lib/plugin/Media.js
index d05762a..8d56da9 100644
--- a/lib/plugin/Media.js
+++ b/lib/plugin/Media.js
@@ -35,12 +35,6 @@ var Media = function(src, successCallback, errorCallback, statusCallback) {
return;
}
- // statusCallback optional
- if (positionCallback && (typeof positionCallback !== "function")) {
- console.log("Media Error: positionCallback is not a function");
- return;
- }
-
this.id = utils.createUUID();
mediaObjects[this.id] = this;
this.src = src;
@@ -155,4 +149,38 @@ Media.prototype.setVolume = function(volume) {
exec(null, null, "Media", "setVolume", [this.id, volume]);
};
+/**
+ * Audio has status update.
+ * PRIVATE
+ *
+ * @param id The media object id (string)
+ * @param status The status code (int)
+ * @param msg The status message (string)
+ */
+Media.onStatus = function(id, msg, value) {
+ var media = mediaObjects[id];
+ // If state update
+ if (msg === Media.MEDIA_STATE) {
+ if (value === Media.MEDIA_STOPPED) {
+ if (media.successCallback) {
+ media.successCallback();
+ }
+ }
+ if (media.statusCallback) {
+ media.statusCallback(value);
+ }
+ }
+ else if (msg === Media.MEDIA_DURATION) {
+ media._duration = value;
+ }
+ else if (msg === Media.MEDIA_ERROR) {
+ if (media.errorCallback) {
+ media.errorCallback({"code":value});
+ }
+ }
+ else if (msg === Media.MEDIA_POSITION) {
+ media._position = value;
+ }
+};
+
module.exports = Media;