积极答复者
c#的uwp程序如何读取视频文件的信息?

问题
答案
-
StorageFile.Properties.GetVideoPropertiesAsync 可以获取一些
try { StorageFile file = rootPage.sampleFile; if (file != null) { StringBuilder outputText = new StringBuilder(); // Get video properties VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync(); outputText.AppendLine("Year: " + videoProperties.Year); outputText.AppendLine("Rating: " + videoProperties.Rating); } } // Handle errors with catch blocks catch (FileNotFoundException) { // For example, handle a file not found error }
- 已标记为答案 BillQu0002 2017年6月8日 7:52
全部回复
-
播放时可以获取
如新的MediaPlaybackSession(14393以上系统)的NaturalVideoWidth 和NaturalVideoHeight 就是宽和高 。老的MediaElement也有相应属性。
参考:
https://docs.microsoft.com/en-us/uwp/api/windows.media.playback.mediaplaybacksession
- 已编辑 Exilerrr 2017年6月5日 14:24
-
StorageFile.Properties.GetVideoPropertiesAsync 可以获取一些
try { StorageFile file = rootPage.sampleFile; if (file != null) { StringBuilder outputText = new StringBuilder(); // Get video properties VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync(); outputText.AppendLine("Year: " + videoProperties.Year); outputText.AppendLine("Rating: " + videoProperties.Rating); } } // Handle errors with catch blocks catch (FileNotFoundException) { // For example, handle a file not found error }
- 已标记为答案 BillQu0002 2017年6月8日 7:52