2013-01-17 48 views
0

我想開發一個用相機拍攝圖像的移動應用程序,最初我想使用phonegap並嘗試爲我的visual studio2010下載和安裝cordovastarter模板,但phonegap的所有版本都給我錯誤......'這個安裝不支持項目類型',所以想放棄使用phonegap的想法,所以接下來的事情是,是否有可能在沒有phonegap的幫助下僅使用html5與相機進行交互?與html5相機交互的移動應用程序?

注意:在使用IM MVC3框架

回答

0

它非常更多鈔票來使用HTML5媒體API的攝像頭互動,但是支持是尚未證實。

HTML部分:因此,正如你所期望的可能無法正常工作

<video id="video" width="640" height="480" autoplay></video> 
<button id="snap">Snap Photo</button> 
<canvas id="canvas" width="640" height="480"></canvas> 

和JavaScript是這樣的:

// Put event listeners into place 
window.addEventListener("DOMContentLoaded", function() { 
// Grab elements, create settings, etc. 
var canvas = document.getElementById("canvas"), 
context = canvas.getContext("2d"), 
video = document.getElementById("video"), 
videoObj = { "video": true }, 
errBack = function(error) { 
    console.log("Video capture error: ", error.code); 
}; 

// Put video listeners into place 
if(navigator.getUserMedia) { // Standard 
navigator.getUserMedia(videoObj, function(stream) { 
    video.src = stream; 
    video.play(); 
}, errBack); 
} else if(navigator.webkitGetUserMedia) { // WebKit-prefixed 
navigator.webkitGetUserMedia(videoObj, function(stream){ 
    video.src = window.webkitURL.createObjectURL(stream); 
    video.play(); 
}, errBack); 
}}, false); 

希望它能幫助,源here