[SelfCamera]update SelfCamera(tizen_2.1)
authorji.ji <ji.ji@samsung.com>
Tue, 4 Jun 2013 07:11:05 +0000 (16:11 +0900)
committerji.ji <ji.ji@samsung.com>
Tue, 4 Jun 2013 07:11:05 +0000 (16:11 +0900)
Change-Id: Id3ada271b1a8f273a510a61e8610691a76b8326b

config.xml
icon.png
js/main.js

index 2c565fa..c74e1b1 100644 (file)
@@ -1,19 +1,14 @@
 <?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>
index 9765b1b..5934757 100644 (file)
Binary files a/icon.png and b/icon.png differ
index 86ff55b..50a55a1 100644 (file)
@@ -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();
                });