[ 
https://issues.apache.org/jira/browse/CB-11148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291433#comment-16291433
 ] 

ASF GitHub Bot commented on CB-11148:
-------------------------------------

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:
[email protected]


> BB10 Media getDuration does not work
> ------------------------------------
>
>                 Key: CB-11148
>                 URL: https://issues.apache.org/jira/browse/CB-11148
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-media
>            Reporter: David Peacock
>              Labels: BlackBerry10, pendingPR, triaged
>
> In the latest media plug-in the getDuration for Blackberry10 will never work. 
>  The javascript code expects onStatus to be called to set the duration.  The 
> getDuration function only returns the value that would have been set from the 
> onStatus.  However, the BB10 code never calls onStatus so the duration will 
> never be set.
> The BB10 code does have a native getDuration function, but this logic will 
> never gets hit.  The create function should result in a callback to onStatus 
> to set the duration.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to