MediaKit.WinUI3
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MediaKit.WinUI3 --version 1.0.1
NuGet\Install-Package MediaKit.WinUI3 -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MediaKit.WinUI3" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MediaKit.WinUI3" Version="1.0.1" />
<PackageReference Include="MediaKit.WinUI3" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MediaKit.WinUI3 --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MediaKit.WinUI3, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MediaKit.WinUI3@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MediaKit.WinUI3&version=1.0.1
#tool nuget:?package=MediaKit.WinUI3&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MediaKit.WinUI3
基于 Win2D PixelShaderEffect + Composition API 的 360 全景视频播放控件,为 WinUI 3 应用提供开箱即用的球面投影渲染。
支持平台
- .NET 8.0
- Windows App SDK 1.8+
- 最低 Windows 版本:10.0.19041.0
- 目标 Windows 版本:10.0.22621.0
安装
dotnet add package MediaKit.WinUI3
或在 NuGet 包管理器中搜索 MediaKit.WinUI3。
命名空间
using MediaKit.WinUI3;
XAML 中引用:
xmlns:mk="using:MediaKit.WinUI3"
功能
PanoMediaElement — 360 全景视频播放器
- 等距柱状投影 → 球面透视投影(GPU 着色器实时渲染)
- 鼠标拖拽旋转 + 惯性滑动
- 滚轮缩放
- 完整的播放控制(播放/暂停/停止/跳转/循环/倍速)
- 视角重置(Reset)
基本用法
XAML
<Page xmlns:mk="using:MediaKit.WinUI3">
<mk:PanoMediaElement x:Name="Player"
Source="{Binding VideoUri}"
AutoPlay="True"
Fov="90"
Zoom="0.5"
IsLooping="True" />
</Page>
Code-Behind
using MediaKit.WinUI3;
// 设置视频源
Player.Source = new Uri("ms-appx:///Assets/360video.mp4");
// 播放控制
Player.Play();
Player.Pause();
Player.Stop();
Player.Seek(TimeSpan.FromSeconds(30));
// 调整视角
Player.Fov = 100;
Player.Zoom = 0.8;
// 重置视角
Player.Reset();
属性说明
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
Source |
Uri | null | 视频源 URI |
RotationX |
double | 0.5 | 水平旋转 [0, 1],0.5 为正前方 |
RotationY |
double | 0.5 | 垂直旋转 [0, 1],0.5 为水平视线 |
Zoom |
double | 0.5 | 缩放级别 [0.1, 2.0] |
Fov |
double | 90.0 | 视场角(度) |
Position |
TimeSpan | 0 | 当前播放位置,外部设置时自动 Seek(内置防抖) |
Duration |
TimeSpan | 0 | 媒体总时长(只读) |
Progress |
double | 0.0 | 播放进度 [0, 100],双向绑定,设置时自动 Seek(内置防抖) |
IsPlaying |
bool | false | 是否正在播放 |
Volume |
double | 1.0 | 音量 [0.0, 1.0] |
IsMuted |
bool | false | 是否静音 |
PlaybackRate |
double | 1.0 | 播放速率 |
AutoPlay |
bool | true | 设置 Source 后是否自动播放 |
IsLooping |
bool | false | 是否循环播放 |
NaturalVideoWidth |
int | 0 | 视频原始宽度(只读) |
NaturalVideoHeight |
int | 0 | 视频原始高度(只读) |
命令(ICommand)
支持 MVVM 命令绑定,无需 Code-Behind:
| 命令 | 说明 |
|---|---|
PlayCommand |
开始播放 |
PauseCommand |
暂停播放 |
StopCommand |
停止并重置到起始位置 |
ResetCommand |
重置视角参数(Fov/Zoom/RotationX/RotationY) |
<Button Command="{x:Bind Player.PlayCommand}" Content="▶" />
<Button Command="{x:Bind Player.PauseCommand}" Content="⏸" />
<Button Command="{x:Bind Player.StopCommand}" Content="⏹" />
<Button Command="{x:Bind Player.ResetCommand}" Content="Reset" />
事件
| 事件 | 参数 | 说明 |
|---|---|---|
MediaOpened |
EventArgs | 媒体打开完成 |
MediaEnded |
EventArgs | 播放结束 |
MediaFailed |
string | 加载或播放失败,参数为错误信息 |
PositionChanged |
TimeSpan | 播放位置变化 |
与 Slider 绑定进度
直接双向绑定 Progress,拖拽时内置防抖防止画面跳跃:
<Slider Minimum="0" Maximum="100"
Value="{x:Bind Player.Progress, Mode=TwoWay}" />
依赖项
- Microsoft.Graphics.Win2D 1.4.0
- Microsoft.WindowsAppSDK 1.8+
许可证
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows10.0.22621 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0-windows10.0.22621
- Microsoft.Graphics.Win2D (>= 1.4.0)
- Microsoft.Windows.SDK.BuildTools (>= 10.0.26100.4654)
- Microsoft.WindowsAppSDK (>= 1.8.260209005)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.