From: ji.ji Date: Tue, 4 Jun 2013 07:11:05 +0000 (+0900) Subject: [SelfCamera]update SelfCamera(tizen_2.1) X-Git-Tag: 2.2_release~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe8ea23e9c71e3caafd9450ca4175a58683dc82a;p=samples%2Fweb%2FSelfCamera.git [SelfCamera]update SelfCamera(tizen_2.1) Change-Id: Id3ada271b1a8f273a510a61e8610691a76b8326b --- diff --git a/config.xml b/config.xml index 2c565fa..c74e1b1 100644 --- a/config.xml +++ b/config.xml @@ -1,19 +1,14 @@ - - - - - + + + + + SelfCamera - - - - - - + + + + + + diff --git a/icon.png b/icon.png index 9765b1b..5934757 100644 Binary files a/icon.png and b/icon.png differ diff --git a/js/main.js b/js/main.js index 86ff55b..50a55a1 100644 --- a/js/main.js +++ b/js/main.js @@ -139,7 +139,7 @@ function SelfCamera() { SelfCamera.prototype.onFileExistsCheck = function (exists) { if (!exists) { - this.setLastPhoto(); + this.setLastPhoto(false); } }; @@ -205,7 +205,7 @@ function SelfCamera() { 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); @@ -329,11 +329,19 @@ function SelfCamera() { 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); } @@ -374,13 +382,27 @@ function SelfCamera() { $('#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', ''); @@ -409,7 +431,7 @@ function SelfCamera() { SelfCamera.prototype.init = function init() { this.getSaveDirectory(function (that) { that.systemIO = new SystemIO(); - that.setLastPhoto(); + that.setLastPhoto(true); that.startPreview(); that.bindEvents(); });