开发者

using the Camera api with phonegap on symbian

I can't figure out why this isn't working.. can't check this on the nokia simulator because it doesn't simulate a camera.. and the phone app either crashes or just don't bring any picture I tried both Base64 method and imageURI method (with different buttons on the html page)

this is the javascript (the reason for the duplicate js for the camera is trying the different methods):

function camera (){

    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camerasuccess,camerafail,null);
};        
function camerasuccess(imageBASE) {

    $('#showpic').css('display','block').html("we have an image");
    var imgsrc = "data:image/jpeg;base64,"+imageBASE[0];
    $('#imageplace').html('<img src ="'+imgsrc+'"/>');
    //var useimg = document.getElementById('useimage');
    //
    //useimg.style.display = 'block';
    //useimg.src = "data:image/jpeg;base64,"+imageBASE;

}

function camerafail(error) {
    $('#showpic').css('display','block').html("some error:"+error);
};

function camera2(){
    $('#showpic').css('display','block').html("getting an image");
    navigator.camera.getPicture(camera2success,camerafail,null);

};

function camer开发者_如何转开发a2success (imageURI){
    $('#showpic').css('display','block').html("we have an image");
    $('#debug').html(imageURI[0]);
    if (!imageURI[0]) {
        $('#debug').html("no imageURI here");
    }
    $('#imageplace').html('<img src ="'+imageURI[0]+'"/>');

and this is the markup (here also the remains of the different approaches I took):

   <div id = "camera">
        <input type = "button" id = "camera" value = "base">
        <input type = "button" id = "camera2" value = "imageURi"></br>
        <span id = "showpic" style = "display:none;">showpic</span><br/>
        <span id = "debug"></span></br>
        <div id = "imageplace"></div></br>
        <img id = "useimage" style = "display:none; width:60px; height:60px " src = ''/> 
    </div>

another notice: if it has any meaning then you should know I don't use make to close the wgz file, just zip the www folder and change the ending to wgz, most js functions (including geolocation) work fine.


I've got a similar problem. I am using a Nokia N8. It fires the getPicture method, and I can take a photo. However the only way to exit from the 'taking a photo' app is to click Back. This fires the success function, but no image data is returned.

Looking at the API docs for Phonegap, it says that these are the supported platforms for the Camera API:

  • Android
  • Blackberry WebWorks (OS 5.0 and higher)
  • iPhone
  • Windows Phone 7 ( Mango )

After much trial and error, this apparently only works if you expect the Camera API to return images as URIs (not the actual image data), and also set editable to true. Try something like this:

navigator.camera.getPicture(camerasuccess, onFail, { quality: 20, allowEdit: true }); 

$('#imageplace').html('<img src ="'+imageBASE+'"/>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜