Windows 8 在WinJS中以编程方式停止视频捕获

Windows 8 在WinJS中以编程方式停止视频捕获,windows-8,video-capture,winjs,Windows 8,Video Capture,Winjs,我有一个winJS,我正在录制视频。虽然我可以让它工作,但我想在15秒后自动停止相机录制。目前,cam记录的时间超过15秒,然后从视频中删除15秒。我希望相机在15秒后自动关闭/停止录制。我有以下代码: function captureVideo() { WinJS.log && WinJS.log("", "sample", "status"); // Using Windows.Media.Capture.CameraCaptureUI API to cap

我有一个winJS,我正在录制视频。虽然我可以让它工作,但我想在15秒后自动停止相机录制。目前,cam记录的时间超过15秒,然后从视频中删除15秒。我希望相机在15秒后自动关闭/停止录制。我有以下代码:

function captureVideo() {
    WinJS.log && WinJS.log("", "sample", "status");

    // Using Windows.Media.Capture.CameraCaptureUI API to capture a video
    var dialog = new Windows.Media.Capture.CameraCaptureUI();

    dialog.videoSettings.allowTrimming = true;
    dialog.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4;
    dialog.videoSettings.maxDurationInSeconds = document.getElementById("txtDuration").value;
    dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).done(function (file) {

        if (file) {

            var videoBlobUrl = URL.createObjectURL(file, {oneTimeOnly: true});
            document.getElementById("capturedVideo").src = videoBlobUrl;
            localSettings.values[videoKey] = file.path;

        } else {
            WinJS.log && WinJS.log("No video captured.", "sample", "status");
        }
    }, function (err) {
        WinJS.log && WinJS.log(err, "sample", "error");
    });
}

您正在使用的CameraCaptureUI为易于使用和标准界面牺牲了电源。如果您需要更多功能,例如启动和停止录制的功能,则应使用MediaCapture对象。见我的朋友。在这本书中,我使用MediaCapture录制音频,但您可能知道如何录制视频,并添加您的计时概念。

谢谢Jeremy。。。我会试试看