From: Pawel Kaczmarczyk
Date: Tue, 13 Feb 2018 08:12:38 +0000 (+0100)
Subject: [Media] Error handling caused by lacking storage privileges added
X-Git-Tag: accepted/tizen/unified/20180514.144930~2^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F170106%2F9;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git
[Media] Error handling caused by lacking storage privileges added
ACR: http://suprem.sec.samsung.net/jira/browse/TWDAPI-187
[Verification]
Tested in Chromium console
tct-media-cordova-tests passrate: 100%
Change-Id: I462b78104d6b9be583540192c5e93e2f97f56b5a
Signed-off-by: Pawel Kaczmarczyk
---
diff --git a/src/lib/plugins/cordova-plugin-media/tizen/Media.js b/src/lib/plugins/cordova-plugin-media/tizen/Media.js
old mode 100755
new mode 100644
index 9dff36b..132826f
--- a/src/lib/plugins/cordova-plugin-media/tizen/Media.js
+++ b/src/lib/plugins/cordova-plugin-media/tizen/Media.js
@@ -351,6 +351,7 @@ cordova.define(plugin_name, function(require, exports, module) {
audioObjects[id].isReady = true;
if (!audioObjects[id].src) {
+
var setSrc = function(id, src) {
//assigning src sets playbackRate to default value equal to 1
//so if playbackRate was set before first run of play() function
@@ -362,11 +363,21 @@ cordova.define(plugin_name, function(require, exports, module) {
};
if(RegExp('^((file\:\/\/)|(/)).*').test(src)) {
- setSrc(id,src);
+ try {
+ tizen.filesystem.resolve(src, function() {
+ setSrc(id, src);
+ }, function(error) {
+ console.log('Filesystem resolve failed');
+ Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message));
+ }, 'r');
+ } catch (error) {
+ console.log('Error during filesystem resolve');
+ Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message));
+ }
return;
}
- if(!RegExp('.*!(\/\/).*').test(src)) {
+ if(RegExp('.*!(\/\/).*').test(src)) {
try {
tizen.filesystem.resolve('documents', function(dir) {
setSrc(id, dir.toURI() + '/' + src);
@@ -379,9 +390,9 @@ cordova.define(plugin_name, function(require, exports, module) {
Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message));
}
return;
- } else {
- setSrc(id, src);
}
+ setSrc(id, src);
+ return;
}
audioObjects[id].play();
@@ -426,8 +437,16 @@ cordova.define(plugin_name, function(require, exports, module) {
startRecordingAudio: function(successCallback, errorCallback, args) {
var id = args[0];
console.log('media::startRecordingAudio()');
-
- recorder.rec();
+ try {
+ tizen.filesystem.resolve('documents', function() {
+ recorder.rec();
+ }, function (error) {
+ Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message));
+ }, 'rw');
+ } catch (error) {
+ Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message));
+ return;
+ }
},
stopRecordingAudio: function(successCallback, errorCallback, args) {
var id = args[0];