You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/01/31 01:27:01 UTC

[1/2] git commit: [ubuntu] add missing file

Updated Branches:
  refs/heads/dev 04398c9c0 -> 65cfc08ef


[ubuntu] add missing file


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/193aeb38
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/193aeb38
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/193aeb38

Branch: refs/heads/dev
Commit: 193aeb38db4ee28b625623e2c009e643e70ae59a
Parents: 04398c9
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Mon Jan 20 18:47:37 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Mon Jan 20 18:47:37 2014 +0400

----------------------------------------------------------------------
 src/ubuntu/MediaCaptureWidget.qml | 207 +++++++++++++++++++++++++++++++++
 1 file changed, 207 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/193aeb38/src/ubuntu/MediaCaptureWidget.qml
----------------------------------------------------------------------
diff --git a/src/ubuntu/MediaCaptureWidget.qml b/src/ubuntu/MediaCaptureWidget.qml
new file mode 100644
index 0000000..cf0b04c
--- /dev/null
+++ b/src/ubuntu/MediaCaptureWidget.qml
@@ -0,0 +1,207 @@
+/*
+ *
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ *
+*/
+import QtQuick 2.0
+import QtMultimedia 5.0
+
+Rectangle {
+    property string recordOffImagePath: "record_off.png"
+    property string recordOnImagePath: "record_on.png"
+    property string shootImagePath: "shoot.png"
+    function isSuffix(str, suffix) {
+        return String(str).substr(String(str).length - suffix.length) == suffix
+    }
+
+    id: ui
+    color: "#252423"
+    anchors.fill: parent
+    state: "off"
+
+    Camera {
+        objectName: "camera"
+        id: camera
+        cameraState: Camera.UnloadedState
+        onError: {
+            console.log(errorString);
+            shootButton.source = recordOffImagePath
+        }
+        imageCapture {
+            onImageSaved: {
+                root.exec("Capture", "onImageSaved", [path]);
+                ui.destroy();
+            }
+        }
+        videoRecorder {
+            audioBitRate: 128000
+            mediaContainer: "mp4"
+            outputLocation: ui.parent.plugin('Capture').generateLocation("mp4")
+            onRecorderStateChanged: {
+               if (videoRecorder.recorderState === CameraRecorder.StoppedState) {
+                   ui.parent.exec("Capture", "onVideoRecordEnd", [camera.videoRecorder.actualLocation]);
+                   shootButton.source = recordOffImagePath
+               }
+            }
+        }
+    }
+    Image {
+        id: microphoneImage
+        source: "microphone.png"
+        smooth: true
+        visible: false
+        width: parent.width
+        height: parent.height
+    }
+    VideoOutput {
+        id: output
+        focus : visible
+        source: camera
+        width: parent.width
+        height: parent.height
+    }
+
+    Item {
+        anchors.bottom: parent.bottom
+        width: parent.width
+        height: shootButton.height
+        BorderImage {
+            id: leftBackground
+            anchors.left: parent.left
+            anchors.top: parent.top
+            anchors.bottom: parent.bottom
+            anchors.right: middle.left
+            anchors.topMargin: units.dp(2)
+            anchors.bottomMargin: units.dp(2)
+            source: "toolbar-left.png"
+            Image {
+                anchors.verticalCenter: parent.verticalCenter
+                anchors.left: parent.left
+                anchors.leftMargin: parent.iconSpacing
+                source: "back.png"
+                width: units.gu(6)
+                height: units.gu(5)
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: {
+                        root.exec("Capture", "cancel");
+                    }
+                }
+            }
+        }
+        BorderImage {
+            id: middle
+            anchors.top: parent.top
+            anchors.bottom: parent.bottom
+            anchors.horizontalCenter: parent.horizontalCenter
+            height: shootButton.height + units.gu(1)
+            width: shootButton.width
+            source: "toolbar-middle.png"
+            Image {
+                id: shootButton
+                width: units.gu(8)
+                height: width
+                anchors.horizontalCenter: parent.horizontalCenter
+                source: shootImagePath
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: {
+                        if (ui.state === "camera") {
+                            camera.imageCapture.captureToLocation(ui.parent.plugin('Capture').generateLocation("jpg"));
+                        } else if (ui.state === "audio") {
+                            ui.parent.exec("Capture", "recordAudio");
+                            if (isSuffix(shootButton.source, recordOffImagePath)) {
+                                shootButton.source = recordOnImagePath
+                            } else {
+                                shootButton.source = recordOffImagePath
+                            }
+                        } else if (ui.state === "videoRecording") {
+                            if (!camera.videoRecorder.recorderState) {
+                                shootButton.source = recordOnImagePath
+                                camera.videoRecorder.record();
+                            } else {
+                                camera.videoRecorder.stop();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        BorderImage {
+            id: rightBackground
+            anchors.right: parent.right
+            anchors.top: parent.top
+            anchors.bottom: parent.bottom
+            anchors.left: middle.right
+            anchors.topMargin: units.dp(2)
+            anchors.bottomMargin: units.dp(2)
+            source: "toolbar-right.png"
+        }
+    }
+    states: [
+        State {
+            name: "off"
+            StateChangeScript {
+                script:{
+		    ui.visible = false;
+                    camera.stop();
+                    camera.unlock();
+                }
+            }
+        },
+        State {
+            name: "camera"
+            StateChangeScript {
+                script: {
+                    camera.start();
+		    microphoneImage.visible = false
+                    output.visible = true
+                    shootButton.source = shootImagePath
+                    ui.visible = true
+                }
+            }
+        },
+        State {
+            name: "videoRecording"
+            StateChangeScript {
+                script: {
+                    shootButton.source = recordOffImagePath
+                    camera.start();
+		    microphoneImage.visible = false
+                    output.visible = true
+                    ui.visible = true
+                }
+            }
+        },
+        State {
+            name: "audio"
+            StateChangeScript {
+                script:{
+                    shootButton.source = recordOffImagePath
+                    camera.stop();
+		    microphoneImage.visible = true
+                    camera.unlock();
+                    output.visible = false
+                    ui.visible = true
+                }
+            }
+        }
+    ]
+}


[2/2] git commit: [ubuntu] request audio/camera/microphone permission

Posted by st...@apache.org.
[ubuntu] request audio/camera/microphone permission


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/65cfc08e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/65cfc08e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/65cfc08e

Branch: refs/heads/dev
Commit: 65cfc08ef34d939119061519328c4fb8f9490e72
Parents: 193aeb3
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Tue Jan 21 15:34:20 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Jan 21 15:34:20 2014 +0400

----------------------------------------------------------------------
 plugin.xml | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/65cfc08e/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 0d146df..a68df82 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -93,6 +93,13 @@ xmlns:android="http://schemas.android.com/apk/res/android"
         <resource-file src="src/ubuntu/toolbar-left.png" />
         <resource-file src="src/ubuntu/toolbar-middle.png" />
         <resource-file src="src/ubuntu/toolbar-right.png" />
+        <config-file target="config.xml" parent="/*">
+            <feature name="Capture">
+                <param policy_group="audio" policy_version="1" />
+                <param policy_group="camera" policy_version="1" />
+                <param policy_group="microphone" policy_version="1" />
+            </feature>
+        </config-file>
     </platform>
 
     <!-- ios -->