<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
- id="http://sample-web-application.tizen.org/SelfCamera" version="2.1.0"
- viewmodes="maximized">
- <access origin="*" subdomains="true" />
- <tizen:application id="QvgnlNAjTV.SelfCamera"
- package="QvgnlNAjTV" required_version="2.1" />
- <content src="index.html" />
- <icon src="icon.png" />
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/SelfCamera" version="2.1.0" viewmodes="maximized">
+ <access origin="*" subdomains="true"/>
+ <tizen:application id="QvgnlNAjTV.SelfCamera" package="QvgnlNAjTV" required_version="2.1"/>
+ <content src="index.html"/>
+ <icon src="icon.png"/>
<name>SelfCamera</name>
- <tizen:privilege name="http://tizen.org/privilege/application.launch" />
- <tizen:privilege name="http://tizen.org/privilege/filesystem.read" />
- <tizen:privilege name="http://tizen.org/privilege/filesystem.write" />
- <tizen:privilege name="http://tizen.org/privilege/content.read" />
- <tizen:privilege name="http://tizen.org/privilege/content.write" />
- <tizen:setting screen-orientation="portrait"
- context-menu="disable" background-support="disable" encryption="disable"
- install-location="auto" />
+ <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
+ <tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
+ <tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
+ <tizen:privilege name="http://tizen.org/privilege/content.read"/>
+ <tizen:privilege name="http://tizen.org/privilege/content.write"/>
+ <tizen:setting screen-orientation="portrait" context-menu="disable" background-support="disable" encryption="disable" install-location="auto"/>
</widget>
SelfCamera.prototype.onFileExistsCheck = function (exists) {
if (!exists) {
- this.setLastPhoto();
+ this.setLastPhoto(false);
}
};
SelfCamera.prototype.saveCanvas = function saveCanvas(canvas, fileName) {
var data, onSuccess = function (fileHandle) {
- this.setLoadDirectory(fileHandle.parent.toURI());
+ this.setLoadDirectory(this.getFileDirectoryURI(fileHandle));
this.loadThumbnail();
this.refreshPhoto(fileHandle);
}.bind(this);
clearInterval(self.countdownIntervalID);
if (self.video !== null) {
if (document.webkitVisibilityState === 'visible') {
- self.createVideoElement(self.src);
- self.systemIO.fileExists(self.filename, self.onFileExistsCheck.bind(self));
- if (self.countdown > 0) {
- self.startCountdown(event, self.countdown);
- }
+ self.getSaveDirectory(function (that) {
+ that.systemIO = new SystemIO();
+ that.createVideoElement(self.src);
+ that.systemIO.fileExists(self.filename, self.onFileExistsCheck.bind(self));
+ $('video').on("stalled", function(e) {
+ this.load();
+ });
+ $('video').on("playing", function() {
+ if (that.countdown > 0) {
+ that.startCountdown(event, that.countdown);
+ }
+ });
+ });
} else {
self.video.parentNode.removeChild(self.video);
}
$('#center').css('margin-left', '-' + ($('#background').width() / 2) + 'px');
};
- SelfCamera.prototype.setLastPhoto = function () {
+ // Fix for file.parent.toURI() + escaping white signs
+ SelfCamera.prototype.getFileDirectoryURI = function (file) {
+ var dirURI;
+ dirURI = encodeURI(
+ file.toURI()
+ .split('/')
+ .slice(0, -1)
+ .join('/')
+ );
+ return dirURI;
+ };
+
+ SelfCamera.prototype.setLastPhoto = function (show) {
this.findLastPhoto(function (file) {
if (file) {
- this.setLoadDirectory(file.parent.toURI());
+ this.setLoadDirectory(this.getFileDirectoryURI(file));
this.setFileName(file.name);
$('#thumbnail').css('background-image', 'url("./images/transparent.png")');
- $('#thumbnail').show();
+ if (show) {
+ $('#thumbnail').show();
+ }
} else {
$('#thumbnail').hide();
$('#upImage').css('background-image', '');
SelfCamera.prototype.init = function init() {
this.getSaveDirectory(function (that) {
that.systemIO = new SystemIO();
- that.setLastPhoto();
+ that.setLastPhoto(true);
that.startPreview();
that.bindEvents();
});