
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia
if (navigator.getUserMedia) {
navigator.getUserMedia({ audio: true, video: { width: 480, height: 360 } },
function(stream) {
var video = document.querySelector('video')
video.src = window.URL.createObjectURL(stream)
video.onloadedmetadata = function(e) {
video.play()
}
},
function(err) {
console.log("发生错误: " + err.name)
}
)
} else {
console.log("警告:该浏览器不支持!")
}
需要加载cordova.js方法:
document.addEventListener("deviceready", onDeviceReady, false)
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType
destinationType = navigator.camera.DestinationType
}
//相册
function fromCamera()
{
var source = pictureSource.PHOTOLIBRARY
navigator.camera.getPicture(function (imageData) {
setimg(imageData)
}, function (message) {
if (source == pictureSource.CAMERA)
alert('加载照相机出错!' + message)
else
alert('加载相册出错!' + message)
}, {
quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source
})
}
//拍照
function EditImgPz()
{
navigator.camera.getPicture(function (imageData) {
setimg(imageData)
}, function (message) {
alert(message)
}, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true
})
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)