使用HTML 5从UIWebView访问iPhone的相机

时间:2011-10-11 11:20:14

标签: iphone html5

我希望找到一种使用iPhone 5使用iPhone相机拍摄和录制视频的方法。我参考了这个文档。 http://www.w3.org/TR/html-media-capture/ 我已尝试在几篇文章中使用HTML Media Capture API。但我无法访问相机。我在我的HTML文件中使用以下代码,该文件在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尚未完全部署?如果是这样,它将在不久的将来?有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:1)

目前不是。您必须使用AppMobi或Apache DeviceReady(Phonegap)等框架才能通过UIWebview中的JavaScript访问本机摄像头。

相关问题