[英]Stop recording video after 15seconds
我试图在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;
}
使用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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.