|
@@ -16,11 +16,17 @@
|
|
|
body{
|
|
|
background-color: #000000;
|
|
|
}
|
|
|
+
|
|
|
.previewer{
|
|
|
width: 100%;
|
|
|
max-height: 100%;
|
|
|
}
|
|
|
|
|
|
+ .previewer.mirror{
|
|
|
+ -webkit-transform: scaleX(-1);
|
|
|
+ transform: scaleX(-1);
|
|
|
+ }
|
|
|
+
|
|
|
#controls{
|
|
|
position: fixed;
|
|
|
left: 0px;
|
|
@@ -40,6 +46,27 @@
|
|
|
width: 5em;
|
|
|
}
|
|
|
|
|
|
+ #verticalUI .settingButton{
|
|
|
+ position: absolute;
|
|
|
+ bottom: 2em;
|
|
|
+ left: 1em;
|
|
|
+ }
|
|
|
+
|
|
|
+ #verticalUI .cameraFunctionPanel{
|
|
|
+ position: fixed;
|
|
|
+ width: 100%;
|
|
|
+ top:0px;
|
|
|
+ left: 0px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #verticalUI .cameraFunctionPanel .camswitch{
|
|
|
+ position: absolute;
|
|
|
+ top: 1em;
|
|
|
+ right: 1em;
|
|
|
+ box-shadow: none;
|
|
|
+ background-color: transparent !important;
|
|
|
+ }
|
|
|
+
|
|
|
#sidewayUI .shutterContainer{
|
|
|
position: fixed;
|
|
|
right: 0px;
|
|
@@ -57,6 +84,28 @@
|
|
|
transform: translateY(-50%);
|
|
|
}
|
|
|
|
|
|
+ #sidewayUI .settingButton{
|
|
|
+ position: fixed;
|
|
|
+ top: 2em;
|
|
|
+ right: 1em;
|
|
|
+ }
|
|
|
+
|
|
|
+ #sidewayUI .cameraFunctionPanel{
|
|
|
+ position: fixed;
|
|
|
+ height: 100%;
|
|
|
+ top:0px;
|
|
|
+ left: 0px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #sidewayUI .cameraFunctionPanel .camswitch{
|
|
|
+ position: absolute;
|
|
|
+ top: 1em;
|
|
|
+ left: 1em;
|
|
|
+ box-shadow: none;
|
|
|
+ background-color: transparent !important;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#shutterCover{
|
|
|
position: fixed;
|
|
|
top:0px;
|
|
@@ -69,18 +118,17 @@
|
|
|
|
|
|
#albumn{
|
|
|
position: fixed;
|
|
|
- bottom: 20px;
|
|
|
- right: 12px;
|
|
|
- width: 6em;
|
|
|
+ bottom: 2em;
|
|
|
+ right: 1em;
|
|
|
}
|
|
|
|
|
|
.ablumnpreview{
|
|
|
- width: 5em;
|
|
|
+ width: 3em;
|
|
|
}
|
|
|
|
|
|
.latestPreview{
|
|
|
- width: 5em !important;
|
|
|
- height: 5em !important;
|
|
|
+ width: 3em !important;
|
|
|
+ height: 3em !important;
|
|
|
}
|
|
|
|
|
|
.zoombarcontainer{
|
|
@@ -117,25 +165,48 @@
|
|
|
<div class="zoombarcontainer">
|
|
|
<input id="zoombar" type="range" min="1" max="100" value="50">
|
|
|
</div>
|
|
|
+ <div></div>
|
|
|
<div id="verticalUI">
|
|
|
+ <div class="cameraFunctionPanel">
|
|
|
+ <div class="ui button small icon basic camswitch" onclick="switchCamera();">
|
|
|
+ <img src="img/icons/camswitch.svg">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="shutterContainer">
|
|
|
<div onclick="takePicture();" ontouchdown="takePicture();">
|
|
|
<img class="ui shutter image" src="img/shutter.png">
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="settingButton">
|
|
|
+ <button onclick="toggleSettings();" class="circular inverted ui icon large button">
|
|
|
+ <i class="setting icon"></i>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div id="sidewayUI">
|
|
|
+ <div class="cameraFunctionPanel">
|
|
|
+ <div class="ui button small icon basic camswitch" onclick="switchCamera();">
|
|
|
+ <img src="img/icons/camswitch.svg">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="shutterContainer">
|
|
|
<div onclick="takePicture();" ontouchdown="takePicture();">
|
|
|
<img class="ui shutter image" src="img/shutter.png">
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="settingButton">
|
|
|
+ <button onclick="toggleSettings();" class="circular inverted ui icon large button">
|
|
|
+ <i class="setting icon"></i>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
<script>
|
|
|
let isMobile = false;
|
|
|
let saveFolder = "user:/Photo/DCIM";
|
|
|
+ let cameraFacingBackground = true;
|
|
|
+ let videoStream = null;
|
|
|
if( /Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
|
|
isMobile = true;
|
|
|
}
|
|
@@ -146,6 +217,7 @@
|
|
|
initcamera();
|
|
|
});
|
|
|
loadAblumnPreview();
|
|
|
+ initVideoDeviceConstraints();
|
|
|
});
|
|
|
|
|
|
$(window).on("resize", function(){
|
|
@@ -177,7 +249,7 @@
|
|
|
ao_module_agirun("Camera/backend/loadLatestPhoto.js", {savetarget: saveFolder}, function(data){
|
|
|
if (data.error !== undefined){
|
|
|
console.log(data.error);
|
|
|
- }else{
|
|
|
+ }else if (data != ""){
|
|
|
$(".latestPreview").attr("src", `../media/?file=${data}`);
|
|
|
console.log(data);
|
|
|
}
|
|
@@ -250,33 +322,65 @@
|
|
|
uploadFile(imageFile, "user:/Photo/DCIM", callback);
|
|
|
}
|
|
|
|
|
|
- function initcamera(){
|
|
|
+ function initVideoDeviceConstraints(){
|
|
|
+ let supports = navigator.mediaDevices.getSupportedConstraints();
|
|
|
+ console.log(supports);
|
|
|
+ if( supports['facingMode'] == false ) {
|
|
|
+ $(".camswitch").addClass("disabled");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function switchCamera(){
|
|
|
+ //Stop all the previous streams
|
|
|
+ videoStream.getTracks().forEach(t => {
|
|
|
+ t.stop();
|
|
|
+ });
|
|
|
+
|
|
|
+ //Toggle the new camera
|
|
|
+ cameraFacingBackground = !cameraFacingBackground;
|
|
|
+ if (cameraFacingBackground){
|
|
|
+ //Use environment
|
|
|
+ $(".previewer").removeClass("mirror");
|
|
|
+ initcamera();
|
|
|
+ }else{
|
|
|
+ //Use user
|
|
|
+ $(".previewer").addClass("mirror");
|
|
|
+ initcamera('user');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function initcamera(facingmode = 'environment'){
|
|
|
//Define the camera constraints
|
|
|
const constraints = {
|
|
|
video: {
|
|
|
width: { ideal: 2048 },
|
|
|
height: { ideal: 1080 },
|
|
|
zoom: true,
|
|
|
- facingMode: 'environment'
|
|
|
+ facingMode: facingmode
|
|
|
},
|
|
|
audio: false
|
|
|
};
|
|
|
+
|
|
|
+ let video = document.querySelector("video");
|
|
|
+ //Just to make sure it is oaused when starting
|
|
|
+ video.pause()
|
|
|
+ video.srcObject = null
|
|
|
|
|
|
- const video = document.querySelector("video");
|
|
|
navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
|
|
|
const [track] = stream.getVideoTracks();
|
|
|
+ videoStream = stream;
|
|
|
try{
|
|
|
const capabilities = track.getCapabilities();
|
|
|
const settings = track.getSettings();
|
|
|
console.log(track, settings);
|
|
|
video.srcObject = stream;
|
|
|
+ video.play();
|
|
|
|
|
|
//Check if zoom exists. If yes, allow zoom
|
|
|
if (!('zoom' in settings)) {
|
|
|
$("#zoombar").hide();
|
|
|
}else{
|
|
|
var input = $("#zoombar")[0];
|
|
|
-
|
|
|
input.min = capabilities.zoom.min;
|
|
|
input.max = capabilities.zoom.max;
|
|
|
input.step = capabilities.zoom.step;
|