[Dialog] change the way of get TV Notification sound path 23/69223/1
authorbg.chun <bg.chun@samsung.com>
Thu, 12 May 2016 07:41:13 +0000 (16:41 +0900)
committerbg.chun <bg.chun@samsung.com>
Thu, 12 May 2016 07:48:55 +0000 (16:48 +0900)
[Verification] Cordova Dialog TCT 100% pass

Change-Id: Ida344bf5d558fd800838100623a49c0902a05af3
Signed-off-by: bg.chun <bg.chun@samsung.com>
src/lib/plugins/cordova-plugin-dialogs/tizen/Notification.js

index 044e5df..0e8b519 100755 (executable)
@@ -25,8 +25,11 @@ var _document = document || {};
 var playback = (function() {
   var soundElement;
   var counter = 1;
+  var soundPathArray = ['/usr/share/feedback/sound/operation/operation.wav', '/usr/share/feedback/sound/operation/back.wav'];
+  var soundPathCount = 0;
 
   function win(v) {
+    console.log('Success to get the notification sound: ' + v);
     soundElement = new Audio(v);
     soundElement.addEventListener('ended', function() {
       if (--counter > 0) {
@@ -39,10 +42,25 @@ var playback = (function() {
     console.error('Failed to get the notification sound: ' + e);
   }
 
+  function recursiveFailCallback(e) {
+    fail(e);
+    console.warn("Retry with another path");
+    
+    if(soundPathCount >= soundPathArray.length){
+      console.error('Failed to get the notification sound: There is no available sound file path');
+      return;
+    }
+
+    tizen.filesystem.resolve(soundPathArray[soundPathCount++], function(file) {
+      win(file.toURI());
+    }, recursiveFailCallback, 'r');
+
+  }
+
   if ('tv' === tizen.systeminfo.getCapability('http://tizen.org/feature/profile').toLowerCase()) {
-    tizen.filesystem.resolve('/usr/share/feedback/sound/operation/operation.wav', function(file) {
+    tizen.filesystem.resolve(soundPathArray[soundPathCount++], function(file) {
       win(file.toURI());
-    }, fail, 'r');
+    }, recursiveFailCallback, 'r');
   } else {
     tizen.systemsetting.getProperty('NOTIFICATION_EMAIL', win, fail);
   }