Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
bd9461b2
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,发现更多精彩内容 >>
提交
bd9461b2
编写于
5月 25, 2023
作者:
J
Jerome Laban
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: Adjust memory cleanup, initial video window position
上级
72125551
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
83 addition
and
30 deletion
+83
-30
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
+11
-0
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
...dIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
+55
-20
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
...ddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
+3
-10
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
+14
-0
未找到文件。
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.cs
浏览文件 @
bd9461b2
...
...
@@ -49,6 +49,17 @@ public partial class GtkMediaPlayer : FrameworkElement
_
=
Initialize
();
}
~
GtkMediaPlayer
()
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Debug
(
"Collecting GtkMediaPlayer"
);
}
_mediaPlayer
?.
Dispose
();
_libvlc
?.
Dispose
();
}
public
string
Source
{
get
=>
(
string
)
GetValue
(
SourceProperty
);
...
...
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/GTKMediaPlayer.events.cs
浏览文件 @
bd9461b2
#
nullable
enable
using
Windows.UI.Core
;
using
LibVLCSharp.GTK
;
using
LibVLCSharp.Shared
;
using
Windows.UI
;
using
Windows.UI.Xaml.Controls
;
using
Microsoft.UI.Xaml
;
using
System
;
using
Windows.UI.Xaml
;
using
System.Threading
;
using
System.Linq
;
using
Windows.UI.Notifications
;
using
Uno.Extensions
;
using
Uno.Logging
;
using
Pango
;
using
Windows.UI.Xaml.Media
;
using
System.Timers
;
using
Timer
=
System
.
Timers
.
Timer
;
using
System.Globalization
;
using
Windows.Media.Playback
;
using
System.Threading.Tasks
;
using
Uno.UI.Runtime.Skia
;
using
System.Runtime.CompilerServices
;
using
System.Diagnostics.CodeAnalysis
;
namespace
Uno.UI.Media
;
...
...
@@ -28,6 +17,8 @@ public partial class GtkMediaPlayer
{
private
Task
?
_initializationTask
;
private
MediaPlayerElement
?
_mpe
;
private
static
ConditionalWeakTable
<
object
,
WeakReference
<
GtkMediaPlayer
>>
_playerMap
=
new
();
private
static
ConditionalWeakTable
<
object
,
WeakReference
<
GtkMediaPlayer
>>
_videoViewMap
=
new
();
public
event
EventHandler
<
object
>?
OnSourceFailed
;
public
event
EventHandler
<
object
>?
OnSourceEnded
;
...
...
@@ -62,6 +53,7 @@ public partial class GtkMediaPlayer
}
_mediaPlayer
=
new
LibVLCSharp
.
Shared
.
MediaPlayer
(
_libvlc
);
_playerMap
.
Add
(
_mediaPlayer
,
new
WeakReference
<
GtkMediaPlayer
>(
this
));
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Debug
))
{
...
...
@@ -69,7 +61,15 @@ public partial class GtkMediaPlayer
}
_videoView
=
new
LibVLCSharp
.
GTK
.
VideoView
();
_videoView
.
VideoSurfaceInteraction
+=
OnVideoViewVideoSurfaceInteraction
;
_videoViewMap
.
Add
(
_videoView
,
new
WeakReference
<
GtkMediaPlayer
>(
this
));
_videoView
.
VideoSurfaceInteraction
+=
static
(
s
,
e
)
=>
{
if
(
GetGtkPlayerForVlcPlayer
(
s
,
out
var
target
))
{
target
.
OnVideoViewVideoSurfaceInteraction
(
s
,
e
);
}
};
});
await
Dispatcher
.
RunAsync
(
CoreDispatcherPriority
.
Normal
,
()
=>
...
...
@@ -92,10 +92,30 @@ public partial class GtkMediaPlayer
_videoView
.
Visible
=
true
;
_videoView
.
MediaPlayer
=
_mediaPlayer
;
_mediaPlayer
.
TimeChanged
+=
OnMediaPlayerTimeChange
;
_mediaPlayer
.
TimeChanged
+=
OnMediaPlayerTimeChangeIsMediaParse
;
_mediaPlayer
.
MediaChanged
+=
MediaPlayerMediaChanged
;
_mediaPlayer
.
Stopped
+=
OnMediaPlayerStopped
;
_mediaPlayer
.
TimeChanged
+=
static
(
s
,
e
)
=>
{
if
(
GetGtkPlayerForVlcPlayer
(
s
,
out
var
target
))
{
target
.
OnMediaPlayerTimeChange
(
s
,
e
);
target
.
OnMediaPlayerTimeChangeIsMediaParse
(
s
,
e
);
}
};
_mediaPlayer
.
MediaChanged
+=
static
(
s
,
e
)
=>
{
if
(
GetGtkPlayerForVlcPlayer
(
s
,
out
var
target
))
{
target
.
MediaPlayerMediaChanged
(
s
,
e
);
}
};
_mediaPlayer
.
Stopped
+=
static
(
s
,
e
)
=>
{
if
(
GetGtkPlayerForVlcPlayer
(
s
,
out
var
target
))
{
target
.
OnMediaPlayerStopped
(
s
,
e
);
}
};
_videoContainer
.
Content
=
_videoView
;
AddChild
(
_videoContainer
);
...
...
@@ -111,6 +131,21 @@ public partial class GtkMediaPlayer
});
}
static
bool
GetGtkPlayerForVlcPlayer
(
object
?
instance
,
[
NotNullWhen
(
true
)]
out
GtkMediaPlayer
?
player
)
{
if
(
instance
is
not
null
&&
_playerMap
.
TryGetValue
(
instance
,
out
var
weakTarget
)
&&
weakTarget
.
TryGetTarget
(
out
player
))
{
return
true
;
}
player
=
null
;
return
false
;
}
private
void
OnVideoViewVideoSurfaceInteraction
(
object
?
sender
,
EventArgs
e
)
{
UpdateMediaPlayerElementReference
();
...
...
@@ -162,6 +197,7 @@ public partial class GtkMediaPlayer
media
.
Parse
(
MediaParseOptions
.
ParseNetwork
);
_mediaPlayer
.
Media
=
media
;
AddMediaEvents
();
OnSourceLoaded
?.
Invoke
(
this
,
EventArgs
.
Empty
);
UpdateVideoStretch
();
...
...
@@ -177,13 +213,12 @@ public partial class GtkMediaPlayer
private
void
AddMediaEvents
()
{
if
(
_mediaPlayer
?.
Media
is
{
IsParsed
:
true
}
media
)
if
(
_mediaPlayer
?.
Media
is
{
}
media
)
{
media
.
DurationChanged
-=
DurationChanged
;
media
.
MetaChanged
-=
MetaChanged
;
media
.
StateChanged
-=
StateChanged
;
media
.
ParsedChanged
-=
ParsedChanged
;
_mediaPlayer
.
TimeChanged
-=
OnMediaPlayerTimeChangeIsMediaParse
;
media
.
DurationChanged
+=
DurationChanged
;
media
.
MetaChanged
+=
MetaChanged
;
...
...
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/MediaPlayerExtension.cs
浏览文件 @
bd9461b2
...
...
@@ -24,6 +24,7 @@ using System.Numerics;
using
Uno.Logging
;
using
Windows.UI.Xaml
;
using
Atk
;
using
System.Runtime.CompilerServices
;
[
assembly
:
ApiExtension
(
typeof
(
IMediaPlayerExtension
),
typeof
(
Uno
.
UI
.
Media
.
MediaPlayerExtension
))]
...
...
@@ -31,7 +32,7 @@ namespace Uno.UI.Media;
public
partial
class
MediaPlayerExtension
:
IMediaPlayerExtension
{
private
static
Dictionary
<
Windows
.
Media
.
Playback
.
MediaPlayer
,
MediaPlayerExtension
>
_instances
=
new
();
private
static
ConditionalWeakTable
<
Windows
.
Media
.
Playback
.
MediaPlayer
,
MediaPlayerExtension
>
_instances
=
new
();
private
Uri
?
_uri
;
private
List
<
Uri
>?
_playlistItems
;
...
...
@@ -58,15 +59,7 @@ public partial class MediaPlayerExtension : IMediaPlayerExtension
lock
(
_instances
)
{
_instances
[
_owner
]
=
this
;
}
}
~
MediaPlayerExtension
()
{
lock
(
_instances
)
{
_instances
.
Remove
(
_owner
);
_instances
.
Add
(
_owner
,
this
);
}
}
...
...
src/AddIns/Uno.UI.MediaPlayer.Skia.Gtk/VideoView.cs
浏览文件 @
bd9461b2
...
...
@@ -53,6 +53,7 @@ namespace LibVLCSharp.GTK
private
MediaPlayer
?
_mediaPlayer
;
private
Gtk
.
Window
?
_videoWindow
;
private
Rectangle
?
_lastArrange
;
internal
event
EventHandler
?
VideoSurfaceInteraction
;
...
...
@@ -79,6 +80,7 @@ namespace LibVLCSharp.GTK
if
(
Visible
)
{
_videoWindow
?.
Show
();
ApplyLastArrange
();
}
else
{
...
...
@@ -171,6 +173,8 @@ namespace LibVLCSharp.GTK
// Show the window once the ID has been associated in libVLC
_videoWindow
.
Show
();
ApplyLastArrange
();
}
}
...
...
@@ -262,6 +266,14 @@ namespace LibVLCSharp.GTK
}
}
private
void
ApplyLastArrange
()
{
if
(
_lastArrange
is
not
null
)
{
Arrange
(
_lastArrange
.
Value
);
}
}
internal
void
Arrange
(
Gdk
.
Rectangle
value
)
{
if
(
this
.
Log
().
IsEnabled
(
Microsoft
.
Extensions
.
Logging
.
LogLevel
.
Trace
))
...
...
@@ -269,6 +281,8 @@ namespace LibVLCSharp.GTK
this
.
Log
().
Trace
(
$"Arranging child window to
{
value
.
X
}
x
{
value
.
Y
}
/
{
value
.
Width
}
x
{
value
.
Height
}
"
);
}
_lastArrange
=
value
;
_videoWindow
?.
Window
.
MoveResize
(
value
.
X
,
value
.
Y
,
value
.
Width
,
value
.
Height
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录