2015-01-02 4 views
1

플랫폼 브라우저가 활성화 된 Cordova 앱이 있습니다. Chrome에서 카메라를 사용하고 싶지만 카메라를 호출해도 전혀 의견이 없습니다. 그것은 내 안드로이드 devide에 매력처럼 작동합니다.Cordorva 브라우저 플랫폼 카메라가 작동하지 않습니다.

내가이 명령을 실행 : cordova run browser

크롬 열립니다 코르도바 설치하는 카메라에 대한 프록시 말해 완벽하게 잘 콘솔 로그 예상대로 :

The key "target-densitydpi" is not supported. 
cordova.js:851 adding proxy for Camera 
index.js:47 Received Event: deviceready 

내가 예를 사용하고 있습니다 https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md.

다음 예에서 내 링크를 누르면 로그 라인 "캡처"이외의 아무 일도 발생하지 않습니다. 오류가없고 아무것도 없습니다. 내 카메라에 액세스하는 것에 대한 허락을 묻지도 않습니다. HTML5 페이지에서 카메라를 테스트했는데 Chrome에서 정상적으로 액세스 할 수 있습니다.

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="format-detection" content="telephone=no" /> 
     <meta name="msapplication-tap-highlight" content="no" /> 
     <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <title>Hello World</title> 
    </head> 
    <body> 
     <div class="app"> 

      <h1>Apache Cordova</h1> 
      <div id="deviceready" class="blink"> 
       <p class="event listening">Connecting to Device</p> 
       <p class="event received">Device is Ready</p> 
      </div> 
      <img id="myImage"/> 
      <a href="javascript: capture()">Camera example</a> 
     </div> 
     <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script> 
     <script type="text/javascript" src="cordova.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 

    <script> 
     function capture() 
     { 
      console.log("capture") 
     navigator.camera.getPicture(onSuccess, onFail, { quality: 50, 
      destinationType: Camera.DestinationType.DATA_URL 
     }); 
     } 

     function onSuccess(imageData) { 
      var image = document.getElementById('myImage'); 
      image.src = "data:image/jpeg;base64," + imageData; 
     } 

     function onFail(message) { 
      alert('Failed because: ' + message); 
     } 
    </script> 
    </body> 
</html> 

index.js 파일은 Cordova에서 생성 한 파일입니다.

cordova -version =>

cordova plugins 4.0.0 => org.apache.cordova.camera 0.3.4 "카메라"

사람이를 통해 저를 인도 할 수 있다면, 나는 그것을 정말로를 appriciate 것이다.

미리 감사드립니다.

/마틴 로컬 파일 웹에 대한 크롬의 한계입니다

답변

2
  • , 당신은 카메라/마이크에 액세스 할 수 없습니다. 해결 방법은 로컬 http 서버를 사용하여 file : //

  • 대신 로컬 호스트에서 실행하는 것입니다. 어쨌든 가장 좋은 해결책은 다음과 같이 플래그를 사용하여 크롬을 시작하는 것입니다. --allow-access-from- 파일

아니면 작동 모질라, 시도 할 수 있습니다 :)

감사를!

+0

Perfect. 나는 나중에 그것을 시도 할 것이다. 당신의 응답을 주셔서 감사합니다. –

관련 문제