Ask / Submit

Revision history [back]

click to hide/show revision 1
initial version

posted 2015-03-31 05:33:33 +0300

I got a response on the maling List: https://lists.sailfishos.org/pipermail/devel/2015-March/005902.html Its true, using only Sailfish.Media and QtMultimedia 5.0 worked perfectly fine:

import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0
import Sailfish.Media 1.0

Page {
    id: page

    Camera {
        id: camera
        flash.mode: Camera.FlashOff
        captureMode: Camera.CaptureStillImage
        focus.focusMode: Camera.FocusContinuous
        imageCapture {
            resolution: "800x600"
            onImageSaved: {
                console.warn("image saved");
            }
            onCaptureFailed: {
                console.error("error: " + camera.imageCapture.errorString);
            }
            onImageCaptured: { // does not work: missing SailfishOS feature
                console.log("Image captured");
            }
        }
        onError: {
            console.error("error: " + camera.errorString);
        }
    }
    Component.onCompleted: {
        console.log(camera.cameraState == Camera.ActiveState)
        console.log("done")
    }
    Component.onDestruction: {
        if (camera.cameraState != Camera.UnloadedState) {
            camera.cameraState = Camera.UnloadedState
        }
    }
    TextSwitch {
        id: activationSwitch
        text: qsTr("Camera active")
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        checked: true
        onCheckedChanged: {
            if(camera.cameraState == Camera.ActiveState){
                camera.cameraState = Camera.UnloadedState;
            }
            else if(camera.cameraState == Camera.UnloadedState){
                camera.cameraState = Camera.ActiveState;
            }
        }
    }
    GStreamerVideoOutput {
        id: videoPreview
        anchors.centerIn: parent
        source: camera
        MouseArea {
            anchors.fill: parent
            onClicked: {
                console.log("capturing");
                camera.imageCapture.captureToLocation("/tmp/test.jpg");
            }
        }
    }
}

I got a response on the maling List: https://lists.sailfishos.org/pipermail/devel/2015-March/005902.html

Its true, using only Sailfish.Media and QtMultimedia 5.0 worked perfectly fine:

import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0
import Sailfish.Media 1.0

Page {
    id: page

    Camera {
        id: camera
        flash.mode: Camera.FlashOff
        captureMode: Camera.CaptureStillImage
        focus.focusMode: Camera.FocusContinuous
        imageCapture {
            resolution: "800x600"
            onImageSaved: {
                console.warn("image saved");
            }
            onCaptureFailed: {
                console.error("error: " + camera.imageCapture.errorString);
            }
            onImageCaptured: { // does not work: missing SailfishOS feature
                console.log("Image captured");
            }
        }
        onError: {
            console.error("error: " + camera.errorString);
        }
    }
    Component.onCompleted: {
        console.log(camera.cameraState == Camera.ActiveState)
        console.log("done")
    }
    Component.onDestruction: {
        if (camera.cameraState != Camera.UnloadedState) {
            camera.cameraState = Camera.UnloadedState
        }
    }
    TextSwitch {
        id: activationSwitch
        text: qsTr("Camera active")
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        checked: true
        onCheckedChanged: {
            if(camera.cameraState == Camera.ActiveState){
                camera.cameraState = Camera.UnloadedState;
            }
            else if(camera.cameraState == Camera.UnloadedState){
                camera.cameraState = Camera.ActiveState;
            }
        }
    }
    GStreamerVideoOutput {
        id: videoPreview
        anchors.centerIn: parent
        source: camera
        MouseArea {
            anchors.fill: parent
            onClicked: {
                console.log("capturing");
                camera.imageCapture.captureToLocation("/tmp/test.jpg");
            }
        }
    }
}