我试图在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;
}
答案 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
}