15秒后停止录制视频

时间:2016-08-05 12:15:55

标签: c# windows-phone windows-10-universal windows-10-mobile

我试图在15秒后停止视频播放,但它无法正常工作。请建议我如何实现这个目标?

CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4;
StorageFile videoFile = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Video);
if (videoFile == null)
{
    // User cancelled photo capture
    return;
}

1 个答案:

答案 0 :(得分:0)

使用System.Timers可以实现这一目标。我对您正在使用的库不太了解,但使用Timer i假设您可以非常轻松地完成它。

 using System.Timers;
 static void Main(string[] args)
    {
        Timer tmr = new Timer();

        int seconds = 15; // Not needed, only for demonstration purposes

        tmr.Interval = 1000 * (seconds); // Interval - how long will it take for the timer to elapse. (In milliseconds)
        tmr.Elapsed += Tmr_Elapsed; // Subscribe to the event
        tmr.Start(); // Run the timer
    }

    private static void Tmr_Elapsed(object sender, ElapsedEventArgs e)
    {
        // Stop the video
    }