Skip to content

Commit a0a38be

Browse files
Added a MediaPlayer visual (audio/video)
1 parent ffae18c commit a0a38be

File tree

14 files changed

+193
-18
lines changed

14 files changed

+193
-18
lines changed

WiceAot.Samples.Gallery/Pages/AboutPage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public AboutPage()
3434
#if NETFRAMEWORK
3535
tb.Text = "Wice for .NET Framework v" + asm.GetInformationalVersion() + " based on DirectN v" + typeof(ComObject).Assembly.GetInformationalVersion() + Environment.NewLine
3636
#else
37-
tb.Text = "Wice for .NET Native AOT v" + asm.GetInformationalVersion() + " based on DirectN AOT v" + typeof(ComObject).Assembly.GetInformationalVersion() + Environment.NewLine
37+
tb.Text = $"Wice {RuntimeInformation.ProcessArchitecture} for .NET Native AOT v{asm.GetInformationalVersion()} based on DirectN AOT v{typeof(ComObject).Assembly.GetInformationalVersion()}" + Environment.NewLine
3838
#endif
3939
+ RuntimeInformation.FrameworkDescription + " - " + DiagnosticsInformation.GetBitness() + Environment.NewLine
4040
+ asm.GetCopyright() + Environment.NewLine
@@ -92,6 +92,7 @@ public AboutPage()
9292
tlb.MinButton!.IsVisible = false;
9393
dlg.Content.Children.Add(tlb);
9494

95+
//TextBox.FontSizeProperty.SetValue(_pg, 12f);
9596
_pg.GroupByCategory = true;
9697
_pg.LiveSync = true;
9798
_pg.MaxWidth = DesiredSize.width * 2 / 3;

WiceAot.Samples.Gallery/Pages/MediaPage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ protected override IEnumerable<SampleList> SampleLists
2222
yield return new PdfViewSampleList();
2323
#if !NETFRAMEWORK
2424
yield return new WebViewSampleList();
25+
yield return new MediaPlayerSampleList();
2526
#endif
2627
}
2728
}
Binary file not shown.

WiceAot.Samples.Gallery/Resources/samples.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,16 @@ gma warning restore IDE0017 // Simplify object initialization
12031203

12041204
// load from .NET embedded resource
12051205
img.Source = Application.CurrentResourceManager.GetWicBitmapSource(Assembly.GetExecutingAssembly(), "Samples.Gallery.Resources.rainier.jpg")!;
1206+
}</sample>
1207+
<sample namespace="Samples.Media.MediaPlayer.MediaPlayerSample">void Layout(Visual parent)
1208+
{
1209+
var player = new MediaPlayer();
1210+
parent.Children.Add(player);
1211+
player.Width = parent.Window!.DipsToPixels(900);
1212+
player.Height = parent.Window!.DipsToPixels(500);
1213+
player.Margin = parent.Window!.DipsToPixels(10);
1214+
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program).Namespace + ".Resources.Big_Buck_Bunny_360_10s_1MB.mp4")!;
1215+
player.Source = MediaSource.CreateFromStream(stream.AsRandomAccessStream(), "video/mp4");
12061216
}</sample>
12071217
<sample namespace="Samples.Media.PdfView.PdfViewSample">void Layout(Visual parent)
12081218
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Wice.Samples.Gallery.Samples.Media.MediaPlayer;
2+
3+
public class MediaPlayerSample : Sample
4+
{
5+
public override string Description => "A Media Player (WinRT) based visual that hosts video content.";
6+
7+
public override void Layout(Visual parent)
8+
{
9+
var player = new Wice.MediaPlayer();
10+
parent.Children.Add(player);
11+
Dock.SetDockType(player, DockType.Top); // remove from display
12+
player.Width = parent.Window!.DipsToPixels(900);
13+
player.Height = parent.Window!.DipsToPixels(500);
14+
player.Margin = parent.Window!.DipsToPixels(10);
15+
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program).Namespace + ".Resources.Big_Buck_Bunny_360_10s_1MB.mp4")!;
16+
player.Source = MediaSource.CreateFromStream(stream.AsRandomAccessStream(), "video/mp4");
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Wice.Samples.Gallery.Samples.Media.MediaPlayer;
2+
3+
namespace Wice.Samples.Gallery.Samples.Media;
4+
5+
public class MediaPlayerSampleList : SampleList
6+
{
7+
public override string IconText => MDL2GlyphResource.Video;
8+
public override string Description => "You can use a MediaPlayer visual to playback video or audio content.";
9+
public override string SubTitle => "A visual that supports displaying audio or video content.";
10+
11+
protected override IEnumerable<Sample> Types
12+
{
13+
get
14+
{
15+
yield return new MediaPlayerSample();
16+
}
17+
}
18+
}

WiceAot.Samples.Gallery/WiceAot.Samples.Gallery.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
<ItemGroup>
2727
<None Remove="Resources\aelyo_flat.png" />
28+
<None Remove="Resources\Big_Buck_Bunny_360_10s_1MB.mp4" />
2829
<None Remove="Resources\lorem-cn.txt" />
2930
<None Remove="Resources\rainier.jpg" />
3031
<None Remove="Resources\sample.pdf" />
@@ -43,6 +44,7 @@
4344

4445
<ItemGroup>
4546
<EmbeddedResource Include="Resources\aelyo_flat.png" />
47+
<EmbeddedResource Include="Resources\Big_Buck_Bunny_360_10s_1MB.mp4" />
4648
<EmbeddedResource Include="Resources\lorem-cn.txt" />
4749
<EmbeddedResource Include="Resources\rainier.jpg" />
4850
<EmbeddedResource Include="Resources\sample.pdf">
@@ -84,6 +86,7 @@
8486
<Using Include="Wice.Samples.Gallery.Pages" />
8587
<Using Include="Wice.Samples.Gallery.Samples" />
8688
<Using Include="Wice.Samples.Gallery.Utilities" />
89+
<Using Include="Windows.Media.Core" />
8790
<Using Include="Windows.UI.Composition" />
8891
<Using Include="Windows.Graphics.DirectX" />
8992

WiceAot/External/DirectN.Extensions.deps.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@
66
"compilationOptions": {},
77
"targets": {
88
".NETCoreApp,Version=v9.0": {
9-
"DirectN.Extensions/1.3.2": {
9+
"DirectN.Extensions/1.4.1": {
1010
"dependencies": {
11-
"DirectNAot": "1.3.2",
11+
"DirectNAot": "1.4.1",
1212
"Microsoft.DotNet.ILCompiler": "9.0.9",
1313
"Microsoft.NET.ILLink.Tasks": "9.0.9",
14-
"DirectN": "1.3.2.1"
14+
"DirectN": "1.4.1.0"
1515
},
1616
"runtime": {
1717
"DirectN.Extensions.dll": {}
1818
}
1919
},
2020
"Microsoft.DotNet.ILCompiler/9.0.9": {},
2121
"Microsoft.NET.ILLink.Tasks/9.0.9": {},
22-
"DirectNAot/1.3.2": {
22+
"DirectNAot/1.4.1": {
2323
"runtime": {
2424
"DirectN.dll": {
25-
"assemblyVersion": "1.3.2.1",
26-
"fileVersion": "1.3.2.1"
25+
"assemblyVersion": "1.4.1.0",
26+
"fileVersion": "1.4.1.0"
2727
}
2828
}
2929
},
30-
"DirectN/1.3.2.1": {
30+
"DirectN/1.4.1.0": {
3131
"runtime": {
3232
"DirectN.dll": {
33-
"assemblyVersion": "1.3.2.1",
34-
"fileVersion": "1.3.2.1"
33+
"assemblyVersion": "1.4.1.0",
34+
"fileVersion": "1.4.1.0"
3535
}
3636
}
3737
}
3838
}
3939
},
4040
"libraries": {
41-
"DirectN.Extensions/1.3.2": {
41+
"DirectN.Extensions/1.4.1": {
4242
"type": "project",
4343
"serviceable": false,
4444
"sha512": ""
@@ -57,12 +57,12 @@
5757
"path": "microsoft.net.illink.tasks/9.0.9",
5858
"hashPath": "microsoft.net.illink.tasks.9.0.9.nupkg.sha512"
5959
},
60-
"DirectNAot/1.3.2": {
60+
"DirectNAot/1.4.1": {
6161
"type": "project",
6262
"serviceable": false,
6363
"sha512": ""
6464
},
65-
"DirectN/1.3.2.1": {
65+
"DirectN/1.4.1.0": {
6666
"type": "reference",
6767
"serviceable": false,
6868
"sha512": ""
2 KB
Binary file not shown.

WiceAot/External/DirectN.deps.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"compilationOptions": {},
77
"targets": {
88
".NETCoreApp,Version=v9.0": {
9-
"DirectN/1.3.2": {
9+
"DirectN/1.4.1": {
1010
"dependencies": {
1111
"Microsoft.DotNet.ILCompiler": "9.0.9",
1212
"Microsoft.NET.ILLink.Tasks": "9.0.9"
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"libraries": {
23-
"DirectN/1.3.2": {
23+
"DirectN/1.4.1": {
2424
"type": "project",
2525
"serviceable": false,
2626
"sha512": ""

0 commit comments

Comments
 (0)