Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
5b4436f9
U
Uno
项目概览
lindexi_gd
/
Uno
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Uno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5b4436f9
编写于
5月 11, 2023
作者:
N
Nick Randolph
提交者:
Jerome Laban
5月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Resizing video for transport controls
上级
6b18dac8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
87 addition
and
24 deletion
+87
-24
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
+31
-22
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
...ddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
+6
-1
src/Uno.UI/UI/Xaml/Controls/MediaPlayerElement/MediaTransportControls.cs
...aml/Controls/MediaPlayerElement/MediaTransportControls.cs
+33
-1
src/Uno.UWP/Media/Playback/IMediaPlayerExtension.cs
src/Uno.UWP/Media/Playback/IMediaPlayerExtension.cs
+5
-0
src/Uno.UWP/Media/Playback/MediaPlayer.cs
src/Uno.UWP/Media/Playback/MediaPlayer.cs
+8
-0
src/Uno.UWP/Media/Playback/MediaPlayer.others.cs
src/Uno.UWP/Media/Playback/MediaPlayer.others.cs
+4
-0
未找到文件。
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
浏览文件 @
5b4436f9
...
...
@@ -32,7 +32,7 @@ public partial class GTKMediaPlayer : Border
private
VideoView
?
_videoView
;
private
double
_ratio
;
Windows
.
UI
.
Xaml
.
Media
.
Stretch
_stretch
=
Windows
.
UI
.
Xaml
.
Media
.
Stretch
.
Uniform
;
private
int
_transportControlAdjust
=
94
;
private
Rect
_transportControlsBounds
;
//public int VideoHeight;
//public int VideoWidth;
public
double
Duration
{
get
;
set
;
}
...
...
@@ -173,8 +173,8 @@ public partial class GTKMediaPlayer : Border
}
UpdateTransportControlHeight
();
var
playerHeight
=
(
double
)
this
.
ActualHeight
-
_transportControl
Adjus
t
;
//
UpdateTransportControlHeight();
var
playerHeight
=
(
double
)
this
.
ActualHeight
-
_transportControl
sBounds
.
Heigh
t
;
var
playerWidth
=
(
double
)
this
.
ActualWidth
;
var
playerRatio
=
playerHeight
/
playerWidth
;
...
...
@@ -263,25 +263,25 @@ public partial class GTKMediaPlayer : Border
}
});
}
protected
void
UpdateTransportControlHeight
()
{
UIElement
?
container
=
VisualTreeHelper
.
GetParent
(
_videoContainer
)
as
UIElement
;
ContentPresenter
?
ContentPresenter
=
VisualTreeHelper
.
GetParent
(
container
)
as
ContentPresenter
;
ContentControl
?
ContentControl
=
VisualTreeHelper
.
GetParent
(
ContentPresenter
)
as
ContentControl
;
MediaPlayerPresenter
?
MediaPlayerPresenter
=
VisualTreeHelper
.
GetParent
(
ContentControl
)
as
MediaPlayerPresenter
;
UIElement
?
MediaPlayerPresenter2
=
VisualTreeHelper
.
GetParent
(
MediaPlayerPresenter
)
as
UIElement
;
if
(
MediaPlayerPresenter2
!=
null
)
{
foreach
(
var
child
in
MediaPlayerPresenter2
.
GetChildren
())
{
if
(
child
is
ContentPresenter
)
{
_transportControlAdjust
=
(
int
)
child
.
DesiredSize
.
Height
;
}
}
}
}
//
protected void UpdateTransportControlHeight()
//
{
//
UIElement? container = VisualTreeHelper.GetParent(_videoContainer) as UIElement;
//
ContentPresenter? ContentPresenter = VisualTreeHelper.GetParent(container) as ContentPresenter;
//
ContentControl? ContentControl = VisualTreeHelper.GetParent(ContentPresenter) as ContentControl;
//
MediaPlayerPresenter? MediaPlayerPresenter = VisualTreeHelper.GetParent(ContentControl) as MediaPlayerPresenter;
//
UIElement? MediaPlayerPresenter2 = VisualTreeHelper.GetParent(MediaPlayerPresenter) as UIElement;
//
if (MediaPlayerPresenter2 != null)
//
{
//
foreach (var child in MediaPlayerPresenter2.GetChildren())
//
{
//
if (child is ContentPresenter)
//
{
//
_transportControlAdjust = (int)child.DesiredSize.Height;
//
}
//
}
//
}
//
}
protected
override
Size
ArrangeOverride
(
Size
finalSize
)
{
...
...
@@ -345,4 +345,13 @@ public partial class GTKMediaPlayer : Border
}
}
internal
void
SetTransportControlsBounds
(
Rect
bounds
)
{
if
(!
_transportControlsBounds
.
Equals
(
bounds
))
{
_transportControlsBounds
=
bounds
;
UpdateVideoStretch
();
}
}
}
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
浏览文件 @
5b4436f9
...
...
@@ -23,6 +23,7 @@ using Windows.UI.Xaml.Controls.Maps;
using
System.Numerics
;
using
Uno.Logging
;
using
Windows.UI.Xaml
;
using
Atk
;
[
assembly
:
ApiExtension
(
typeof
(
IMediaPlayerExtension
),
typeof
(
Uno
.
UI
.
Media
.
MediaPlayerExtension
))]
...
...
@@ -38,7 +39,6 @@ public partial class MediaPlayerExtension : IMediaPlayerExtension
private
GTKMediaPlayer
?
_player
;
private
bool
_updatingPosition
;
private
bool
_isPlayRequested
;
private
bool
_isPlayerPrepared
;
...
...
@@ -372,6 +372,11 @@ public partial class MediaPlayerExtension : IMediaPlayerExtension
public
double
AudioBalance
{
get
;
set
;
}
public
void
SetTransportControlsBounds
(
Rect
bounds
)
{
_player
?.
SetTransportControlsBounds
(
bounds
);
}
public
void
SetUriSource
(
Uri
uri
)
{
//if (this.Log().IsEnabled(LogLevel.Debug))
...
...
src/Uno.UI/UI/Xaml/Controls/MediaPlayerElement/MediaTransportControls.cs
浏览文件 @
5b4436f9
...
...
@@ -7,6 +7,7 @@ using Windows.UI.Xaml.Data;
using
Windows.UI.Xaml.Input
;
using
Windows.UI.Xaml.Media
;
using
Uno.UI.Xaml.Controls.MediaPlayer.Internal
;
using
System.Drawing
;
#if __IOS__
using
UIKit
;
...
...
@@ -241,6 +242,10 @@ namespace Windows.UI.Xaml.Controls
_compactOverlayButton
.
Tapped
-=
UpdateMediaTransportControlMode
;
_compactOverlayButton
.
Tapped
+=
UpdateMediaTransportControlMode
;
_controlPanelGrid
=
this
.
GetTemplateChild
(
ControlPanelGridName
)
as
Grid
;
_controlPanelGrid
.
SizeChanged
-=
ControlPanelGridSizeChanged
;
_controlPanelGrid
.
SizeChanged
+=
ControlPanelGridSizeChanged
;
_repeatVideoButton
=
this
.
GetTemplateChild
(
RepeatVideoButtonName
)
as
Button
;
_repeatVideoButton
?.
SetBinding
(
Button
.
VisibilityProperty
,
new
Binding
{
Path
=
"IsRepeatButtonVisible"
,
Source
=
this
,
Mode
=
BindingMode
.
OneWay
,
FallbackValue
=
Visibility
.
Collapsed
,
Converter
=
trueToVisible
});
_repeatVideoButton
?.
SetBinding
(
Button
.
IsEnabledProperty
,
new
Binding
{
Path
=
"IsRepeatEnabled"
,
Source
=
this
,
Mode
=
BindingMode
.
OneWay
,
FallbackValue
=
true
});
...
...
@@ -305,6 +310,11 @@ namespace Windows.UI.Xaml.Controls
}
}
private
void
ControlPanelGridSizeChanged
(
object
sender
,
SizeChangedEventArgs
args
)
{
OnControlsBoundsChanged
();
}
private
void
FullWindowButtonTapped
(
object
sender
,
RoutedEventArgs
e
)
{
_mpe
.
IsFullWindow
=
!
_mpe
.
IsFullWindow
;
...
...
@@ -361,6 +371,7 @@ namespace Windows.UI.Xaml.Controls
{
VisualStateManager
.
GoToState
(
this
,
"ControlPanelFadeIn"
,
false
);
});
OnControlsBoundsChanged
();
}
public
void
Hide
()
...
...
@@ -374,6 +385,23 @@ namespace Windows.UI.Xaml.Controls
VisualStateManager
.
GoToState
(
this
,
"ControlPanelFadeOut"
,
false
);
}
});
OnControlsBoundsChanged
();
}
private
void
OnControlsBoundsChanged
()
{
var
root
=
(
XamlRoot
.
Content
as
UIElement
);
if
(
root
is
null
)
{
return
;
}
var
transportBounds
=
this
.
TransformToVisual
(
root
)
.
TransformBounds
(
new
Foundation
.
Rect
(
0
,
0
,
_controlPanelGrid
.
ActualWidth
,
_isInteractive
?
_controlPanelGrid
.
ActualHeight
:
0
));
this
.
_mediaPlayer
?.
SetTransportControlBounds
(
transportBounds
);
}
private
void
OnPaneGridTapped
(
object
sender
,
TappedRoutedEventArgs
e
)
...
...
@@ -409,11 +437,15 @@ namespace Windows.UI.Xaml.Controls
private
void
UpdateMediaTransportControlMode
()
{
VisualStateManager
.
GoToState
(
this
,
IsCompact
?
"CompactMode"
:
"NormalMode"
,
true
);
OnControlsBoundsChanged
();
}
private
static
void
OnIsCompactChanged
(
DependencyObject
dependencyObject
,
DependencyPropertyChangedEventArgs
args
)
{
VisualStateManager
.
GoToState
((
MediaTransportControls
)
dependencyObject
,
(
bool
)
args
.
NewValue
?
"CompactMode"
:
"NormalMode"
,
false
);
if
(
dependencyObject
is
MediaTransportControls
mtc
)
{
mtc
.
UpdateMediaTransportControlMode
();
}
}
private
static
void
OnShowAndHideAutomaticallyChanged
(
DependencyObject
dependencyObject
,
DependencyPropertyChangedEventArgs
args
)
...
...
src/Uno.UWP/Media/Playback/IMediaPlayerExtension.cs
浏览文件 @
5b4436f9
...
...
@@ -89,6 +89,11 @@ namespace Uno.Media.Playback
/// </summary>
TimeSpan
Position
{
get
;
set
;
}
/// <summary>
/// Sets the transport controls bounds so that video can be displayed around controls
/// </summary>
void
SetTransportControlsBounds
(
Rect
bounds
);
/// <summary>
/// Sets the source from a Uri
/// </summary>
...
...
src/Uno.UWP/Media/Playback/MediaPlayer.cs
浏览文件 @
5b4436f9
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Security.AccessControl
;
using
Windows.Foundation
;
...
...
@@ -93,5 +94,12 @@ namespace Windows.Media.Playback
}
partial
void
OnOptionChanged
(
string
name
,
object
value
);
internal
void
SetTransportControlBounds
(
Rect
bounds
)
{
OnTransportControlBoundsChanged
(
bounds
);
}
partial
void
OnTransportControlBoundsChanged
(
Rect
bounds
);
}
}
src/Uno.UWP/Media/Playback/MediaPlayer.others.cs
浏览文件 @
5b4436f9
...
...
@@ -9,6 +9,7 @@ using Uno.Foundation.Logging;
using
Windows.Foundation
;
using
Uno.Media.Playback
;
using
Windows.ApplicationModel.Email
;
using
System.Drawing
;
namespace
Windows.Media.Playback
{
...
...
@@ -39,6 +40,9 @@ namespace Windows.Media.Playback
partial
void
OnOptionChanged
(
string
name
,
object
value
)
=>
_extension
?.
OnOptionChanged
(
name
,
value
);
partial
void
OnTransportControlBoundsChanged
(
Rect
bounds
)
=>
_extension
?.
SetTransportControlsBounds
(
bounds
);
public
void
Dispose
()
=>
_extension
?.
Dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录