簡體   English   中英

使用Ionic / AngularJS和Cordova的原生和Web應用程序相機

[英]Use camera for both native and web app with Ionic/AngularJS and Cordova

我正在嘗試使用相機,我想知道你是否有任何關於如何使它在web / native上工作的例子。

我有這段代碼,借用了ng-cordova doc:

    $scope.takePicture = function() {
        var options = {
            quality: 75,
            destinationType: Camera.DestinationType.DATA_URL,
            sourceType: Camera.PictureSourceType.CAMERA,
            allowEdit: true,
            encodingType: Camera.EncodingType.JPEG,
            targetWidth: 100,
            targetHeight: 100,
            popoverOptions: CameraPopoverOptions,
            saveToPhotoAlbum: false
        };

        $cordovaCamera.getPicture(options).then(function(imageData) {
            // Success! Image data is here
        }, function(err) {
            // An error occured. Show a message to the user
        });
    }

當我使用它時,它適用於我的設備,但在Web版本中發現錯誤

ReferenceError: Camera is not defined

這就是為什么我問你是否有任何好的方法來做到這一點。 我可以模擬隱藏輸入的點擊,但看起來不漂亮。 如果你有任何想法:)

您可以為Cordova和標准瀏覽器提供攝像頭訪問的實現。 可以使用此實現標准瀏覽器實現

http://www.html5rocks.com/en/tutorials/getusermedia/intro/

W3選秀

並檢查,無論您是在應用程序中運行還是在瀏覽器中運行,都可以使用

ionic.Platform.platform()

記錄在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM