console.log(files[i].fullPath);
if(!(files[i].name in playfiles) ){
playfiles[files[i].name] = files[i];
- table.row.add([i + '.', '/opt/usr/media/Documents/' + files[i].name]).draw(false);
+ table.row.add([i + '.', 'documents/' + files[i].name]).draw(false);
}
}
});
console.log(files[i].fullPath);
if(!(files[i].name in playfiles) ){
playfiles[files[i].name] = files[i];
- table.row.add([i + '.', '/opt/usr/media/Documents/' + files[i].name]).draw(false);
+ table.row.add([i + '.', 'documents' + files[i].name]).draw(false);
}
}
});
'cordova_media_api.js',
'cordova_media_extension.cc',
'cordova_media_extension.h',
+ 'cordova_media_instance.h',
+ 'cordova_media_instance.cc',
],
'include_dirs': [
'../',
],
'variables': {
'packages': [
+ 'storage',
'webapi-plugins',
],
},
// TODO: remove when added to public cordova repository -> begin
var plugin_name = 'cordova-plugin-media.tizen.Media';
+var utils_ = xwalk.utils;
+var native_ = new utils_.NativeManager(extension);
+var privilege_ = xwalk.utils.privilege;
+
+function GetRealPath(virtualPath) {
+
+ console.log("JS GetRealPath " + virtualPath);
+ xwalk.utils.checkPrivilegeAccess(privilege_.FILESYSTEM_READ);
+
+ var data = {
+ path : virtualPath
+ };
+
+ var result = native_.callSync('CordovaMediaInstance_GetRealPath', data);
+ var fullResult = native_.getResultObject(result);
+ console.log("Result of call " + fullResult.path);
+ return fullResult.path;
+}
+
cordova.define(plugin_name, function(require, exports, module) {
// TODO: remove -> end
create: function(successCallback, errorCallback, args) {
var id = args[0], src = args[1];
- console.log('media::create() - id =' + id + ', src =' + src);
+ var realPath = GetRealPath(src);
+ console.log('media::create() - id =' + id + ', src =' + realPath);
- recorder = new Recorder(src);
+ recorder = new Recorder(realPath);
audioObjects[id] = new Audio();
audioObjects[id].isReady = false;
startPlayingAudio: function(successCallback, errorCallback, args) {
var id = args[0], src = args[1];
- console.log('media::startPlayingAudio() - id =' + id + ', src =' + src);
+ var realPath = GetRealPath(src);
+ console.log('media::startPlayingAudio() - id =' + id + ', src =' + realPath);
audioObjects[id].isReady = true;
//it should be saved and restored.
var rate = audioObjects[id].playbackRate;
- audioObjects[id].src = src;
+ audioObjects[id].src = realPath;
audioObjects[id].playbackRate = rate;
return;
}
var id = args[0];
console.log('media::getCurrentPositionAudio()');
if (audioObjects[id].src === 'undefined') {
- audioObjects[id].src = args[1];
+ audioObjects[id].src = GetRealPath(args[1]);
}
successCallback(audioObjects[id].currentTime);
},
var id = args[0];
console.log('media::startRecordingAudio()');
if (audioObjects[id].src === 'undefined') {
- audioObjects[id].src = args[1];
+ audioObjects[id].src = GetRealPath(args[1]);
}
recorder.rec();
},
var id = args[0];
console.log('media::stopRecordingAudio()');
if (audioObjects[id].src === 'undefined') {
- audioObjects[id].src = args[1];
+ audioObjects[id].src = GetRealPath(args[1]);
}
recorder.stop();
},
*/
#include "media/cordova_media_extension.h"
+#include "media/cordova_media_instance.h"
// This will be generated from cordova_media_api.js
extern const char kSource_cordova_media_api[];
CordovaMediaExtension::~CordovaMediaExtension() {}
+common::Instance* CordovaMediaExtension::CreateInstance() {
+ LoggerD("Entered");
+ return new extension::cordova::media::CordovaMediaInstance();
+}
+
} // media
} // cordova
} // extension
public:
CordovaMediaExtension();
virtual ~CordovaMediaExtension();
+
+ private:
+ // common::Extension implementation.
+ virtual common::Instance* CreateInstance();
};
} //media
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "media/cordova_media_instance.h"
+#include <common/logger.h>
+
+namespace extension {
+namespace cordova {
+namespace media {
+
+CordovaMediaInstance::CordovaMediaInstance(): fs_provider_(common::FilesystemProviderStorage::Create()) {
+ LoggerD("Entered");
+
+ RegisterSyncHandler("CordovaMediaInstance_GetRealPath",
+ std::bind(&CordovaMediaInstance::GetRealPath, this, std::placeholders::_1, std::placeholders::_2));
+
+}
+
+CordovaMediaInstance::~CordovaMediaInstance() {
+}
+
+void CordovaMediaInstance::GetRealPath(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+
+ const std::string& path_str = args.get("path").get<std::string>();
+
+ picojson::value retval = picojson::value(picojson::object());
+ picojson::object& obj = retval.get<picojson::object>();
+
+ LoggerD("Path is %s", path_str.c_str());
+ std::string realPath = fs_provider_.GetRealPath(path_str);
+ obj["path"] = picojson::value(realPath);
+ LoggerD("Real Path is %s", realPath.c_str());
+ ReportSuccess(retval,out);
+}
+
+}
+}
+} /* namespace media */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_CORDOVA_MEDIA_EXTENSION_H_
+#define MEDIA_CORDOVA_MEDIA_EXTENSION_H_
+
+#include <common/extension.h>
+#include <common/picojson.h>
+#include <common/filesystem/filesystem_provider_storage.h>
+
+namespace extension {
+namespace cordova {
+namespace media {
+
+class CordovaMediaInstance : public common::ParsedInstance {
+ public:
+ CordovaMediaInstance();
+ virtual ~CordovaMediaInstance();
+
+ private:
+ common::FilesystemProviderStorage& fs_provider_;
+ void GetRealPath(const picojson::value& args, picojson::object& out);
+};
+
+}
+}
+} /* namespace media */
+
+#endif // MEDIA_CORDOVA_MEDIA_EXTENSION_H_