I have a WinUI 3 project that requires the user to submit a video file, I have been assuming that the framerate is 30fps as it requires time calculations. But I would like the app to automatically get the framerate from metadata, or some other way as I know some video files don’t have framerate data.
The following is how I get the file using a filepicker.
private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker fileOpenPicker = new()
{
ViewMode = PickerViewMode.Thumbnail,
FileTypeFilter = { ".mp4" },
};
if (App.m_window != null)
{
nint windowHandle = WindowNative.GetWindowHandle(App.m_window);
InitializeWithWindow.Initialize(fileOpenPicker, windowHandle);
StorageFile file = await fileOpenPicker.PickSingleFileAsync();
if (file != null)
{
PickAFileOutputTextBlock.Text = "Picked file: " + file.Name + "nPath: " + file.Path;
Frame.Navigate(typeof(VideoView), file);
}
else
{
PickAFileOutputTextBlock.Text = "Operation cancelled.";
}
}
else
{
PickAFileOutputTextBlock.Text = "Window handle is not initialized.";
}
}