使用HTML 5从UIWebView访问iPhone的相机 [英] Access iPhone's camera from UIWebView using HTML 5
问题描述
我希望找到一种使用iPhone 5使用iPhone相机拍摄和录制视频的方法。我参考了这个文档。
http://www.w3.org/TR/html-media- capture /
我已尝试使用HTML Media Capture API,如几篇文章中所述。但我无法访问相机。我在我的HTML文件中使用以下代码,该文件在UIWebView中呈现。
I am looking to find a way to shoot and record video using the iPhone's camera using HTML 5. I referred this document. http://www.w3.org/TR/html-media-capture/ I have tried using the HTML Media Capture API as told in several posts. But I cannot access the camera. I'm using the following code in my HTML file which is rendered in an UIWebView.
//A choose file button which is actually disabled came up.
<input type="file" accept="image/*" capture="camera" id="capture">
无效。
这段代码,
//Didn't worked
window.navigator.getUserMedia('audio, video', function(){
alert('Success');
}
, function(){
alert('Error');
});
最后这一个,
//This came up as [object Navigator]
alert(navigator);
//This came up as undefined.
alert(navigator.device);
iPhone中的视频捕获实际上是否可以通过HTML 5实现?这是否意味着HTML 5的Media Capture API尚未完全部署?如果是这样,它将在不久的将来?有人能指出我正确的方向吗?
Is video capture in iPhone actually possible via HTML 5? Does this means that Media Capture API of HTML 5 is not yet fully deployed? If so will it be in near future? Could someone point me in the right direction?
推荐答案
目前不是。您必须使用AppMobi或Apache DeviceReady(Phonegap)等框架才能通过UIWebview中的JavaScript访问本机摄像头。
Not currently. You will have to use a framework like AppMobi or Apache DeviceReady(Phonegap) to get access to the native camera via JavaScript in a UIWebview.
这篇关于使用HTML 5从UIWebView访问iPhone的相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!