[英]Video capture for Windows 8 desktop App (HTML + javascript). Not from webcam
我正在使用HTML和Javascript開發用於桌面的Windows 8.1應用程序。 我有一張視頻采集卡,我想在我的應用程序中實時查看正在捕獲的視頻。 在互聯網上搜索,我發現了一些示例和捕獲Windows 8 App視頻的教程,但是所有這些都與網絡攝像頭一起使用,我想知道這是否適用於任何“捕獲設備”(例如我的捕獲卡) 。
我沒有成功完成此MSDN教程。
http://msdn.microsoft.com/en-us/library/windows/apps/hh452791.aspx
編輯(添加更多信息):
如果您按照本教程進行操作,則可以通過下面的代碼檢測捕獲設備,從而正確檢測到我的捕獲卡。
var deviceInfo = Windows.Devices.Enumeration.DeviceInformation;
deviceInfo.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture).then(function (devices) {
// Add the devices to deviceList
if (devices.length > 0) {
for (var i = 0; i < devices.length; i++) {
deviceList.push(devices[i]);
}
initCaptureSettings();
initMediaCapture();
document.getElementById("message").innerHTML = "Initialization complete.";
} else {
document.getElementById("error").innerHTML("No video device is found ");
}
}, errorHandler);
但是隨后,它在以下代碼部分的“ oMediaCapture.initializeAsync(captureInitSettings)”處引發“訪問被拒絕”異常:
// Create and initialze the MediaCapture object.
function initMediaCapture() {
oMediaCapture = null;
oMediaCapture = new Windows.Media.Capture.MediaCapture();
oMediaCapture.initializeAsync(captureInitSettings).then (function (result) {
createProfile();
}, errorHandler);
}
我認為這可能是因為對捕獲設備有某種訪問權限。 有什么幫助嗎?
提前致謝!!
如果您只關心視頻而又不想使用音頻,則只需確保傳遞給InitializeAsync()的設置正確指定了StreamingCaptureMode:
mediaCapture = new MediaCapture();
MediaCaptureInitializationSettings initSettings = new MediaCaptureInitializationSettings();
initSettings.VideoDeviceId = Webcam.Id;
initSettings.StreamingCaptureMode = StreamingCaptureMode.Video; // <----
await mediaCapture.InitializeAsync(initSettings);
對Slimacik表示敬意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.