匹克在Android中使用PhoneGap的图像/视频 [英] Pick an image / video using PhoneGap in Android

查看:168
本文介绍了匹克在Android中使用PhoneGap的图像/视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能选择一个图像/视频(或拍摄照片/视频)在Android中使用PhoneGap的?

How can I pick an image / video ( or take a photo / video ) using PhoneGap in Android ?

我有一个Web表单需要挑图像/视频内容,并提交表单上传的内容。 PhoneGap的是能够这样做呢?或者我必须退回到原生的Andr​​oid codeS?

I have a web form needs to pick image / video contents and submit the form to upload the contents. Is PhoneGap capable to do so? or I have to fall back to native Android codes?

推荐答案

是的,你可以上传图像与PhoneGap的服务器

Yes you can upload image to server with phonegap

下面是code挑选图像或视频

Here is the code to pick image or video

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
}

在HTML中你必须写

in html you have to write

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

视频

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     }

甚至可以通过这个

even you can go through this

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

这篇关于匹克在Android中使用PhoneGap的图像/视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆