-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
44 lines (40 loc) · 1.86 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace UWP_Codec_Info {
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Windows.Media.Core;
using Windows.UI.Xaml.Controls;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage: Page {
public MainPage() {
this.InitializeComponent();
}
async Task EnumerateCodecs() {
try {
var codecQuery = new CodecQuery();
var videoEncoders = await codecQuery.FindAllAsync(CodecKind.Video, CodecCategory.Encoder, "");
var audioEncoders = await codecQuery.FindAllAsync(CodecKind.Audio, CodecCategory.Encoder, "");
var videoDecoders = await codecQuery.FindAllAsync(CodecKind.Video, CodecCategory.Decoder, "");
var audioDecoders = await codecQuery.FindAllAsync(CodecKind.Audio, CodecCategory.Decoder, "");
var allCodecs = videoEncoders.Concat(audioEncoders).Concat(videoDecoders).Concat(audioDecoders);
this.DataContext = new ObservableCollection<CodecViewModel>(allCodecs.Select(c => new CodecViewModel(c)));
} catch (TypeInitializationException) {
this.DataContext = new ObservableCollection<CodecViewModel> {
new CodecViewModel {
Category = CodecCategory.Encoder,
DisplayName = "Windows N editions are not supported",
Features = string.Empty,
Kind = CodecKind.Audio,
},
};
}
}
async void Page_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
await this.EnumerateCodecs();
}
}
}