2012-10-29 3 views
1

안드로이드에서 PhoneGap을 사용하여 이미지/비디오를 선택하거나 (사진/비디오 촬영) 어떻게 할 수 있습니까?안드로이드에서 PhoneGap을 사용하여 이미지/비디오 선택

웹 양식을 사용하여 이미지/비디오 콘텐츠를 선택하고 양식을 제출하여 콘텐츠를 업로드해야합니다. PhoneGap이 그렇게 할 수 있습니까? 아니면 기본 Android 코드로 돌아 가야합니까?

답변

3

예를 여기

폰갭

으로 서버에 이미지를 업로드 할 수 있습니다 당신이 비디오

에 대한

<button class="btn large" onclick="capturePhoto();">Capture Photo</button> 
<button class="btn large" onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From 
     Photo Library</button> 

를 작성해야 HTML에서

document.addEventListener("deviceready", onDeviceReady, false); 

function onDeviceReady() { 
    pictureSource = navigator.camera.PictureSourceType; 
    destinationType = navigator.camera.DestinationType; 
} 

    function capturePhoto() { 
    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
    destinationType: destinationType.FILE_URI }); 
} 

function getPhoto(source) { 
    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
    destinationType: destinationType.FILE_URI, 
    sourceType: source }); 
} 

function onPhotoURISuccess(imageURI) { 
    // do whatever with imageURI 
} 

이미지 나 비디오를 선택하는 코드이다

Camera.MediaType = { 
    PICTURE: 0,    // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType 
    VIDEO: 1,    // allow selection of video only, WILL ALWAYS RETURN FILE_URI 
    ALLMEDIA : 2  } 

심지어 당신이

http://docs.phonegap.com/en/1.4.0/phonegap_camera_camera.md.html#Camera

+0

통해 갈 수 있지만 누가 SOURCETYPE와 COmeara.MediaType을 사용할 수 있나요? – Hunt

관련 문제