From: lin qunfang Date: Wed, 16 May 2018 20:01:45 +0000 (+0800) Subject: [common][cordova][update all the cordova plugins to the latest] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F179214%2F1;p=test%2Ftct%2Fweb%2Fapi.git [common][cordova][update all the cordova plugins to the latest] Change-Id: I2995fc977b4274ce08dd0c2f201bd1d48382bfa0 Signed-off-by: lin qunfang --- diff --git a/common/tct-device-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-device-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/cordova.js b/common/tct-device-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/cordova_plugins.js b/common/tct-device-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-device-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-devicemotion-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-devicemotion-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/cordova.js b/common/tct-devicemotion-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/cordova_plugins.js b/common/tct-devicemotion-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-devicemotion-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-dialogs-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-dialogs-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/cordova.js b/common/tct-dialogs-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/cordova_plugins.js b/common/tct-dialogs-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-dialogs-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-events-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-events-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/cordova.js b/common/tct-events-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/cordova_plugins.js b/common/tct-events-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/tizen/Notification.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/tizen/Notification.js index 9b1143d53..8e56f2d70 100755 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/tizen/Notification.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/tizen/Notification.js @@ -25,7 +25,7 @@ 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/home.wav']; + var soundPathArray = ['/usr/share/feedback/sound/operation/operation.wav', '/usr/share/feedback/sound/operation/home.wav', '/usr/share/feedback/sound/operation/back.wav']; var soundPathCount = 0; function win(v) { diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/tizen/Globalization.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/tizen/Globalization.js index 4c5131e28..eb2388f31 100755 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/tizen/Globalization.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/tizen/Globalization.js @@ -59,28 +59,48 @@ function Globalization_dateToString(timestamp, successCb, errorCb, options) { var formatLength = (options && options.formatLength) || FORMAT_SHORT_STR; var selector = (options && options.selector) || SELECTOR_DATE_AND_TIME_STR; - tizen.cordova.globalization.dateToString(timestamp, formatLength, selector, successCb, errorCb); + try { + tizen.cordova.globalization.dateToString(timestamp, formatLength, selector, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_stringToDate(dateString, successCb, errorCb, options) { var formatLength = (options && options.formatLength) || FORMAT_SHORT_STR; var selector = (options && options.selector) || SELECTOR_DATE_AND_TIME_STR; - tizen.cordova.globalization.stringToDate(dateString, formatLength, selector, successCb, errorCb); + try { + tizen.cordova.globalization.stringToDate(dateString, formatLength, selector, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_getDatePattern(successCb, errorCb, options) { var formatLength = (options && options.formatLength) || FORMAT_SHORT_STR; var selector = (options && options.selector) || SELECTOR_DATE_AND_TIME_STR; - tizen.cordova.globalization.getDatePattern(formatLength, selector, successCb, errorCb); + try { + tizen.cordova.globalization.getDatePattern(formatLength, selector, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_getDateNames(successCb, errorCb, options) { var type = (options && options.type) || TYPE_WIDE; var item = (options && options.item) || ITEM_MONTHS; - tizen.cordova.globalization.getDateNames(type, item, successCb, errorCb); + try { + tizen.cordova.globalization.getDateNames(type, item, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_isDayLightSavingsTime(timestamp, successCb, errorCb) { @@ -98,29 +118,54 @@ function Globalization_isDayLightSavingsTime(timestamp, successCb, errorCb) { } function Globalization_getFirstDayOfWeek(successCb, errorCb) { - tizen.cordova.globalization.getFirstDayOfWeek(successCb, errorCb); + try { + tizen.cordova.globalization.getFirstDayOfWeek(successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_numberToString(number, successCb, errorCb, options) { var type = (options && options.type) || NUMBER_TYPE_DECIMAL; - tizen.cordova.globalization.numberToString(number, type, successCb, errorCb); + try { + tizen.cordova.globalization.numberToString(number, type, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_stringToNumber(numberStr, successCb, errorCb, options) { var type = (options && options.type) || NUMBER_TYPE_DECIMAL; - tizen.cordova.globalization.stringToNumber(numberStr, type, successCb, errorCb); + try { + tizen.cordova.globalization.stringToNumber(numberStr, type, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_getNumberPattern(successCb, errorCb, options) { var type = (options && options.type) || NUMBER_TYPE_DECIMAL; - tizen.cordova.globalization.getNumberPattern(type, successCb, errorCb); + try { + tizen.cordova.globalization.getNumberPattern(type, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } function Globalization_getCurrencyPattern(currencyCode, successCb, errorCb) { - tizen.cordova.globalization.getCurrencyPattern(currencyCode, successCb, errorCb); + try { + tizen.cordova.globalization.getCurrencyPattern(currencyCode, successCb, errorCb); + } catch (e) { + errorCb(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR, + 'globalization not initialized')); + } } exports = { diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-events-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-file-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-file-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/cordova.js b/common/tct-file-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/cordova_plugins.js b/common/tct-file-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-file-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-file-transfer-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-file-transfer-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/cordova.js b/common/tct-file-transfer-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/cordova_plugins.js b/common/tct-file-transfer-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-file-transfer-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-globalization-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-globalization-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/cordova.js b/common/tct-globalization-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/cordova_plugins.js b/common/tct-globalization-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-globalization-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-media-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-media-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/cordova.js b/common/tct-media-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/cordova_plugins.js b/common/tct-media-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-media-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'), diff --git a/common/tct-network-information-cordova-tests/cordova/cordova-5.1.1.js b/common/tct-network-information-cordova-tests/cordova/cordova-5.1.1.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/cordova.js b/common/tct-network-information-cordova-tests/cordova/cordova.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/cordova_plugins.js b/common/tct-network-information-cordova-tests/cordova/cordova_plugins.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-console/www/console-via-logger.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-console/www/logger.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/Acceleration.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device-motion/www/accelerometer.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-device/www/device.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js old mode 100755 new mode 100644 index 9331997c5..45b8e7995 --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-dialogs/www/notification.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-dialogs.notification", function(require, exports, * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'); diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-events/www/register.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransfer.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file-transfer/www/FileTransferError.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/Errors.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/File.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js old mode 100755 new mode 100644 index e5921660d..c3443152b --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/FileWriter.js @@ -21,7 +21,13 @@ cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports var convertTizenFileError = require('cordova-plugin-file.tizen.Errors'); var rootUtils = require('cordova-plugin-file.tizen.rootUtils'); -// https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +//Code created with the help of Stack Overflow question +//http://stackoverflow.com/a/18729931 +//Question by don kaka: +//https://stackoverflow.com/users/2408835/don-kaka +//Answer by Joni and Damian: +//https://stackoverflow.com/users/318758/joni +//https://stackoverflow.com/users/3390/damian function toUTF8Array(str) { var utf8 = []; for (var i = 0; i < str.length; ++i) { diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/fileSystems-roots.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/tizen/rootUtils.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/DirectoryReader.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Entry.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/File.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileEntry.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileError.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileReader.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadOptions.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileUploadResult.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/FileWriter.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Flags.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/LocalFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/Metadata.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/ProgressEvent.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystemPaths.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js old mode 100755 new mode 100644 index 187d111f0..9dee94311 --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems-roots.js @@ -17,6 +17,7 @@ cordova.define("cordova-plugin-file.fileSystems-roots", function(require, export * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ // Map of fsName -> FileSystem. diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/fileSystems.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/requestFileSystem.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/GlobalizationError.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-globalization/www/globalization.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js index 0f29b19be..9dff36b12 100755 --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/tizen/Media.js @@ -19,6 +19,19 @@ var plugin_name = 'cordova-plugin-media.tizen.Media'; cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end + function MediaError (code, msg) { + Object.defineProperties(this, { + code: { + value: code || null, + writable: false + }, + message: { + value: msg || "", + writable: false + } + }); + } + Object.assign(MediaError, window.MediaError); var audioObjects = {}; var recorder = null; @@ -27,7 +40,7 @@ cordova.define(plugin_name, function(require, exports, module) { var audioContext = window.AudioContext || window.webkitAudioContext; var context = new audioContext(); - function Recorder(_filename) { + function Recorder(_filename, _errorCallback) { var recorder = null; var recording = false; var recordingLength = 0; @@ -36,25 +49,38 @@ cordova.define(plugin_name, function(require, exports, module) { var sampleRate = null; var filename = _filename; var audioBlob = null; + var leftchannel; + var rightchannel; + var errorCallback = _errorCallback; this.rec = function(){ - - if (!navigator.getUserMedia) + if (navigator.mediaDevices.getUserMedia){ + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onGetUserMedia) + .catch(function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }); + } else { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; - - if (navigator.getUserMedia){ - navigator.getUserMedia({audio:true}, onGetUserMedia, function(e) { - console.log('Error capturing audio.'); - }); - } else { - console.log('getUserMedia not supported in this browser.'); + if(navigator.getUserMedia) { + navigator.getUserMedia({audio: true}, onGetUserMedia, function(e) { + console.log('Error capturing audio: ' + e.name + ': ' + e.message); + }) + } else { + console.log('getUserMedia not supported in this browser.'); + } } } this.stop = function (){ recording = false; - audioBlob.stop(); + var tracks = audioBlob.getAudioTracks(); + + tracks.forEach(function(track) { + track.stop(); + }); + recorder.disconnect(); // flat the left and right channels down @@ -100,8 +126,6 @@ cordova.define(plugin_name, function(require, exports, module) { function onGetUserMedia(stream){ recording = true; - var leftchannel = []; - var rightchannel = []; recordingLength = 0; audioBlob = stream; @@ -123,8 +147,10 @@ cordova.define(plugin_name, function(require, exports, module) { Lower values for buffer size will result in a lower (better) latency. Higher values will be necessary to avoid audio breakup and glitches */ var bufferSize = 2048; - recorder = context.createJavaScriptNode(bufferSize, 2, 2); + recorder = context.createScriptProcessor(bufferSize, 2, 2); + rightchannel = []; + leftchannel = []; recorder.onaudioprocess = function(sample){ if (!recording) { return; @@ -150,26 +176,39 @@ cordova.define(plugin_name, function(require, exports, module) { } function onsuccess(dir) { - var recFile = dir.createFile(filename); - if (recFile != null) { - recFile.openStream('w', function (fs) { - fs.writeBytes(arr); - fs.close(); - }, function (error) { - console.log('Error ' + error.message); - }, 'UTF-8'); + var recFile + try { + recFile = dir.createFile(filename); + if (recFile != null) { + recFile.openStream('w', function (fs) { + try { + fs.writeBytes(arr); + fs.close(); + } catch (error) { + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + }, function (error) { + console.log('Failed to open stream error: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'UTF-8'); + } + } catch (error) { + console.log('Error during saving record to file'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } function onerror(error) { console.log('The error ' + error + ' occurred when resolving documents folder'); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } try { tizen.filesystem.resolve('documents', onsuccess, onerror, 'rw'); } catch(error) { - console.log('Caught error ' + error); + console.log('Caught error during documents folder resolve: ' + error.message); + errorCallback(new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); } } @@ -213,7 +252,10 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::create() - id =' + id + ', src =' + src); - recorder = new Recorder(src); + recorder = new Recorder(src, function(error) { + console.log('Recorder error callback'); + Media.onStatus(id, Media.MEDIA_ERROR, error); + }); audioObjects[id] = new Audio(); audioObjects[id].isReady = false; @@ -243,16 +285,12 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].onErrorCB = function (event) { var err = event.srcElement.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ? - { code: MediaError.MEDIA_ERR_ABORTED } : + new MediaError(MediaError.MEDIA_ERR_ABORTED) : event.srcElement.error; - Object.freeze(err); console.log('media::onErrorCB() - MEDIA_ERROR -> ' + err); Media.onStatus(id, Media.MEDIA_ERROR, err); - if (errorCallback) { - errorCallback(err); - } }; audioObjects[id].onPlayCB = function () { @@ -313,14 +351,37 @@ cordova.define(plugin_name, function(require, exports, module) { audioObjects[id].isReady = true; if (!audioObjects[id].src) { - //assigning src sets playbackRate to default value equal to 1 - //so if playbackRate was set before first run of play() function - //it should be saved and restored. - var rate = audioObjects[id].playbackRate; + 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 + //it should be saved and restored. + var rate = audioObjects[id].playbackRate; + + audioObjects[id].src = src; + audioObjects[id].playbackRate = rate; + }; + + if(RegExp('^((file\:\/\/)|(/)).*').test(src)) { + setSrc(id,src); + return; + } - audioObjects[id].src = src; - audioObjects[id].playbackRate = rate; - return; + if(!RegExp('.*!(\/\/).*').test(src)) { + try { + tizen.filesystem.resolve('documents', function(dir) { + setSrc(id, dir.toURI() + '/' + src); + }, function(error) { + console.log('Documents filesystem resolve failed'); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + }, 'r'); + } catch (error) { + console.log('Caught error during documents folder resolve: ' + error.message); + Media.onStatus(id, Media.MEDIA_ERROR, new MediaError(MediaError.MEDIA_ERR_ABORTED, error.message)); + } + return; + } else { + setSrc(id, src); + } } audioObjects[id].play(); @@ -338,16 +399,6 @@ cordova.define(plugin_name, function(require, exports, module) { console.log('media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED'); - audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); - audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); - audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); - audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); - audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); - audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); - audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); - audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); }, seekToAudio: function(successCallback, errorCallback, args) { @@ -369,30 +420,35 @@ cordova.define(plugin_name, function(require, exports, module) { getCurrentPositionAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::getCurrentPositionAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + successCallback(audioObjects[id].currentTime); }, startRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::startRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.rec(); }, stopRecordingAudio: function(successCallback, errorCallback, args) { var id = args[0]; console.log('media::stopRecordingAudio()'); - if (audioObjects[id].src === 'undefined') { - audioObjects[id].src = args[1]; - } + recorder.stop(); }, release: function(successCallback, errorCallback, args) { exports.stopPlayingAudio(successCallback, errorCallback, args); var id = args[0]; + + audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB); + audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB); + audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB); + audioObjects[id].removeEventListener('durationchange', audioObjects[id].onDurationChangeCB); + audioObjects[id].removeEventListener('playing', audioObjects[id].onPlayingCB); + audioObjects[id].removeEventListener('play', audioObjects[id].onPlayCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB); + audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB); + audioObjects[id].removeEventListener('seeked', audioObjects[id].onSeekedCB); + delete audioObjects[id]; console.log('media::release()'); }, diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js old mode 100755 new mode 100644 index 337825391..7e3199b1c --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/Media.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.Media", function(require, exports, module) * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var argscheck = require('cordova/argscheck'), diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js old mode 100755 new mode 100644 index 79b65f683..de998a5f8 --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-media/www/MediaError.js @@ -18,6 +18,7 @@ cordova.define("cordova-plugin-media.MediaError", function(require, exports, mod * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/Connection.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/tizen/NetworkStatus.js old mode 100755 new mode 100644 diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js old mode 100755 new mode 100644 index 1450e9537..b8412e5aa --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/Connection.js @@ -16,7 +16,7 @@ cordova.define("cordova-plugin-network-information.Connection", function(require * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ /** diff --git a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js old mode 100755 new mode 100644 index bfac2e3f9..206a8f7b8 --- a/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js +++ b/common/tct-network-information-cordova-tests/cordova/plugins/cordova-plugin-network-information/www/network.js @@ -16,6 +16,7 @@ cordova.define("cordova-plugin-network-information.network", function(require, e * specific language governing permissions and limitations * under the License. * + * Modifications copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved */ var exec = require('cordova/exec'),