2016-08-05 114 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