Windows Runtime API: MediaCapture 如何限制录制文件的大小

Windows Runtime API: MediaCapture how to limit recording file size

对于 Windows.Media.Capture.MediaCapture,我们可以指定一个大小限制以便触发此事件 (RecordLimitationExceededEventHandler) 并停止录制吗?

如果不是,监视文件大小的正确方法是什么。

谢谢!

你没有提出这个事件,是OS提出的,你只需要处理停止记录。

如果您想监控文件大小,您可以使用 FileSystemWatcher 等。

来自MSDN

If an app receives a RecordLimitationExceeded event, it is expected to finalize the file it is recording. If it does not finalize, the capture engine will stop sending samples to the file that the app was recording to.

In Windows 8, the current record limit is three hours.

所以平台会为您发起这个活动

如果您对限制文件大小感兴趣,FileSystemWatcher MSDN page 上有一个关于如何监视文件更改的很好示例。查找 Changed 事件,并检查 ChangeType 参数。