You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2017/12/14 19:30:59 UTC
[GitHub] surajpindoria closed pull request #95: CB-11148 - BB10 Media getDuration does not work
surajpindoria closed pull request #95: CB-11148 - BB10 Media getDuration does not work
URL: https://github.com/apache/cordova-plugin-media/pull/95
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index e48fafa3..543eb38e 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -23,6 +23,8 @@
var audioObjects = {},
mediaErrorsHandled = false;
+
+var MEDIA_DURATION = 2;
// There is a bug in the webplatform handling of media error
// dialogs prior to 10.2. This function needs to be run once
@@ -44,6 +46,23 @@ function handleMediaErrors() {
}
}
+function setDuration(id, env) {
+ var counter = 0;
+ var interval = 100;
+ var timerDuration = setInterval(function() {
+ counter += interval;
+ if (counter > 2000) {
+ clearInterval(timerDuration);
+ }
+ var duration = audioObjects[id].duration;
+ if (isFinite(duration)) {
+ clearInterval(timerDuration);
+ var executeString = "Media.onStatus('" + id + "', " + MEDIA_DURATION + ", '" + duration + "');";
+ env.webview.executeJavaScript(executeString);
+ }
+ }, interval);
+}
+
module.exports = {
create: function (success, fail, args, env) {
@@ -64,7 +83,9 @@ module.exports = {
}
handleMediaErrors();
-
+
+ setDuration(id, env);
+
result.ok();
},
@@ -183,26 +204,6 @@ module.exports = {
result.ok(audio.currentTime);
},
- getDuration: function (success, fail, args, env) {
-
- var audio,
- result = new PluginResult(args, env);
-
- if (!args[0]) {
- result.error("Media Object id was not sent in arguments");
- return;
- }
-
- audio = audioObjects[JSON.parse(decodeURIComponent(args[0]))];
-
- if (!audio) {
- result.error("Audio Object has not been initialized");
- return;
- }
-
- result.ok(audio.duration);
- },
-
startRecordingAudio: function (success, fail, args, env) {
var result = new PluginResult(args, env);
result.error("Not supported");
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org