简体   繁体   中英

Stop recording video after 15seconds

I am trying to stop video playback after 15 seconds but it's not working. Please suggest me how to achieve this?

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

Using System.Timers you can achieve that. I don't know much about the library you are using, but using Timer i assume you can do it pretty easily.

 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
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM