2016-08-05 92 views
1

我试图在15秒后停止视频播放,但它不起作用。请告诉我如何做到这一点?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

使用System.Timers你可以实现这一点。我对你使用的库不太了解,但是使用Timer我认为你可以很容易地做到这一点。

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 
    } 
+0

使用System.Timers名字空间不是windows10提供phone.Suggest我如何做到这一点感谢@ Cybrus – Robert

+0

@Robert请参考这个帖子:[链接](http://stackoverflow.com/问题/ 22012056 /定时器的窗口电话-8) – Cybrus