Advertisement
Guest User

Phonegap 1.8 attempt to get camera working

a guest
Jun 14th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.    
  3.  
  4.     var pictureSource;   // picture source
  5.     var destinationType; // sets the format of returned value
  6.  
  7.     document.addEventListener("deviceready",onDeviceReady,false);
  8.  
  9.     function onDeviceReady() {
  10.         pictureSource=navigator.camera.PictureSourceType;
  11.         destinationType=navigator.camera.DestinationType;
  12.     }
  13.  
  14.     function onPhotoDataSuccess(imageData) {
  15.         //  navigator.notification.alert("win");
  16.       var smallImage = document.getElementById('smallImage');
  17.       // smallImage.style.display = 'block';
  18.       smallImage.src = "data:image/jpeg;base64," + imageData;
  19.       draw(smallImage);
  20.     }
  21.  
  22.  
  23.     function capturePhoto() {
  24.         if (navigator.camera) {
  25.             navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 25, destinationType: destinationType.DATA_URL });
  26.         } else {
  27.             console.log("phonegap camera not available");
  28.         }
  29.     }
  30.  
  31.  
  32.     function onFail(message) {
  33.         //navigator.notification.alert("fail");
  34.       alert('Failed because: ' + message);
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement