Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
72125551
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,发现更多精彩内容 >>
提交
72125551
编写于
5月 25, 2023
作者:
J
Jerome Laban
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: Adjust fullscreen support
上级
ec0279da
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
96 deletion
+71
-96
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
+5
-72
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
...dIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
+17
-4
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
+49
-20
未找到文件。
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
浏览文件 @
72125551
...
...
@@ -30,9 +30,7 @@ public partial class GtkMediaPlayer : FrameworkElement
private
VideoView
?
_videoView
;
private
Uri
?
_mediaPath
;
private
bool
_isEnding
;
private
bool
_isPlaying
;
private
bool
_isLoopingEnabled
;
private
long
_currentPositionBeforeFullscreenChange
;
private
double
_playbackRate
;
private
Rect
_transportControlsBounds
;
private
Windows
.
UI
.
Xaml
.
Media
.
Stretch
_stretch
=
Windows
.
UI
.
Xaml
.
Media
.
Stretch
.
Uniform
;
...
...
@@ -154,84 +152,19 @@ public partial class GtkMediaPlayer : FrameworkElement
public
void
ExitFullScreen
()
{
if
(
EnsureMediaPlayerAndVideoView
(
))
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"ExitFullScreen"
);
}
_isPlaying
=
_mediaPlayer
.
State
==
VLCState
.
Playing
;
_currentPositionBeforeFullscreenChange
=
_mediaPlayer
.
Time
;
Stop
();
_
=
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
async
()
=>
{
await
Initialize
();
UpdateMedia
();
_
=
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
()
=>
{
UpdateVideoStretch
();
Play
();
Pause
();
CurrentPosition
=
(
double
)
_currentPositionBeforeFullscreenChange
;
if
(
_isPlaying
)
{
Play
();
}
});
});
}
else
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"Unable to exit fullscreen, the player is not ready yet"
);
}
this
.
Log
().
Debug
(
"ExitFullScreen"
);
}
}
public
void
RequestFullScreen
()
{
if
(
EnsureMediaPlayerAndVideoView
(
))
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"RequestFullScreen"
);
}
_isPlaying
=
_mediaPlayer
.
State
==
VLCState
.
Playing
;
_currentPositionBeforeFullscreenChange
=
_mediaPlayer
.
Time
;
Stop
();
_
=
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
async
()
=>
{
await
Initialize
();
UpdateMedia
();
_
=
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
()
=>
{
UpdateVideoStretch
();
Play
();
Pause
();
CurrentPosition
=
(
double
)
_currentPositionBeforeFullscreenChange
;
if
(
_isPlaying
)
{
Play
();
}
});
});
}
else
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"Unable to request fullscreen, the player is not ready yet"
);
}
this
.
Log
().
Debug
(
"RequestFullScreen"
);
}
}
public
void
Stop
()
...
...
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
浏览文件 @
72125551
...
...
@@ -26,14 +26,15 @@ namespace Uno.UI.Media;
public
partial
class
GtkMediaPlayer
{
private
Task
?
_initializationTask
;
private
MediaPlayerElement
?
_mpe
;
public
event
EventHandler
<
object
>?
OnSourceFailed
;
public
event
EventHandler
<
object
>?
OnSourceEnded
;
public
event
EventHandler
<
object
>?
OnMetadataLoaded
;
public
event
EventHandler
<
object
>?
OnTimeUpdate
;
public
event
EventHandler
<
object
>?
OnSourceLoaded
;
private
Task
?
_initializationTask
;
private
async
Task
Initialize
()
{
if
(
_initializationTask
is
null
)
...
...
@@ -112,12 +113,24 @@ public partial class GtkMediaPlayer
private
void
OnVideoViewVideoSurfaceInteraction
(
object
?
sender
,
EventArgs
e
)
{
if
(
_owner
.
FindFirstParent
<
MediaPlayerElement
>()
is
{
}
mpe
)
UpdateMediaPlayerElementReference
();
if
(
_mpe
is
not
null
)
{
_mpe
.
TransportControls
.
Show
();
}
else
{
mpe
.
TransportControls
.
Show
();
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
$"Unable to find a MediaPlayerElement instance to show the transport controls"
);
}
}
}
private
void
UpdateMediaPlayerElementReference
()
=>
_mpe
??=
_owner
.
FindFirstParent
<
MediaPlayerElement
>();
private
void
OnSourceVideoLoaded
(
object
?
sender
,
EventArgs
e
)
{
if
(
_videoView
!=
null
)
...
...
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
浏览文件 @
72125551
...
...
@@ -68,8 +68,8 @@ namespace LibVLCSharp.GTK
Core
.
Initialize
();
Realized
+=
(
s
,
e
)
=>
Attach
();
Unrealized
+=
(
s
,
e
)
=>
Detach
();
Realized
+=
(
s
,
e
)
=>
Attach
ToWidget
();
Unrealized
+=
(
s
,
e
)
=>
Detach
FromWidget
();
}
internal
void
SetVisible
(
bool
visible
)
...
...
@@ -99,24 +99,32 @@ namespace LibVLCSharp.GTK
return
;
}
De
tach
();
De
stroyChildWindow
();
_mediaPlayer
=
value
;
Attach
();
CreateChildWindow
();
}
}
private
void
Attach
()
private
void
CreateChildWindow
()
{
if
(
!
IsRealized
||
_mediaPlayer
==
null
)
if
(
_mediaPlayer
==
null
)
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
$"Unable to attach player (
IsRealized:
{
IsRealized
}
,
_mediaPlayer:
{
_mediaPlayer
is
not
null
}
)"
);
this
.
Log
().
Debug
(
$"Unable to attach player (_mediaPlayer:
{
_mediaPlayer
is
not
null
}
)"
);
}
return
;
}
if
(
_videoWindow
is
not
null
)
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
$"VideoView is already attached, skipping"
);
}
}
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"Attaching player"
);
...
...
@@ -149,13 +157,29 @@ namespace LibVLCSharp.GTK
// Hide it immediately so it does not show outside of our own window
_videoWindow
.
Hide
();
// Reparent the window to the current window, so it appears inside.
_videoWindow
.
Window
.
Reparent
(
Toplevel
.
Window
,
0
,
0
);
AssignWindowId
();
// Show the window once the ID has been associated in libVLC
_videoWindow
.
Show
();
AttachToWidget
();
}
private
void
AttachToWidget
()
{
if
(
IsRealized
&&
_videoWindow
is
not
null
)
{
// Reparent the window to the current window, so it appears inside.
_videoWindow
.
Window
.
Reparent
(
Toplevel
.
Window
,
0
,
0
);
// Show the window once the ID has been associated in libVLC
_videoWindow
.
Show
();
}
}
private
void
DetachFromWidget
()
{
if
(!
IsRealized
&&
_videoWindow
is
not
null
)
{
_videoWindow
.
Hide
();
}
}
private
void
OnVideoWindowMotionNotifyEvent
(
object
o
,
MotionNotifyEventArgs
args
)
...
...
@@ -203,7 +227,19 @@ namespace LibVLCSharp.GTK
}
}
void
Detach
()
private
void
DestroyChildWindow
()
{
RemoveWindowId
();
if
(
_videoWindow
is
not
null
)
{
_videoWindow
.
Hide
();
_videoWindow
.
Destroy
();
_videoWindow
=
null
;
}
}
private
void
RemoveWindowId
()
{
if
(
_mediaPlayer
is
not
null
)
{
...
...
@@ -224,13 +260,6 @@ namespace LibVLCSharp.GTK
throw
new
PlatformNotSupportedException
();
}
}
if
(
_videoWindow
is
not
null
)
{
_videoWindow
.
Hide
();
_videoWindow
.
Destroy
();
_videoWindow
=
null
;
}
}
internal
void
Arrange
(
Gdk
.
Rectangle
value
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录