Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
efe20c33
U
Uno
项目概览
lindexi_gd
/
Uno
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
efe20c33
编写于
6月 16, 2023
作者:
R
Rafael Rosa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: fix plaback state when autoplay not work
上级
42df67b3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
2 deletion
+61
-2
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.NativeMethods.cs
....MediaPlayer.WebAssembly/HtmlMediaPlayer.NativeMethods.cs
+11
-0
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs
+41
-1
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.d.ts
....UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.d.ts
+1
-0
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.js
...no.UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.js
+3
-0
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/ts/MediaElement.ts
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/ts/MediaElement.ts
+4
-0
src/Uno.UI/UI/Xaml/Controls/MediaPlayerElement/MediaTransportControls.MediaPlayer.cs
.../MediaPlayerElement/MediaTransportControls.MediaPlayer.cs
+1
-1
未找到文件。
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.NativeMethods.cs
浏览文件 @
efe20c33
...
...
@@ -47,6 +47,17 @@ partial class HtmlMediaPlayer
=>
throw
new
NotSupportedException
();
#endif
#if USE_JSIMPORT
[
JSImport
(
"globalThis.Uno.UI.Media.HtmlMediaPlayer.getPaused"
)]
#endif
internal
static
partial
bool
GetPaused
(
nint
htmlId
);
#if !USE_JSIMPORT
internal
static
partial
bool
GetPaused
(
nint
htmlId
)
=>
throw
new
NotSupportedException
();
#endif
#if USE_JSIMPORT
[
JSImport
(
"globalThis.Uno.UI.Media.HtmlMediaPlayer.setCurrentPosition"
)]
#endif
...
...
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs
浏览文件 @
efe20c33
...
...
@@ -12,6 +12,7 @@ using System.Globalization;
using
Windows.UI.Xaml.Controls.Maps
;
using
Windows.UI.Xaml.Media
;
using
Windows.UI.Notifications
;
using
System.Numerics
;
namespace
Uno.UI.Media
;
...
...
@@ -68,6 +69,7 @@ internal partial class HtmlMediaPlayer : Border
StatusPlayChanged
+=
OnHtmlStatusPlayChanged
;
StatusPauseChanged
+=
OnHtmlStatusPauseChanged
;
SourceFailed
+=
OnHtmlSourceFailed
;
SourceSuspend
+=
OnHtmlSourceSuspend
;
SourceEnded
+=
OnHtmlSourceEnded
;
MetadataLoaded
+=
OnHtmlMetadataLoaded
;
...
...
@@ -84,6 +86,7 @@ internal partial class HtmlMediaPlayer : Border
StatusPlayChanged
-=
OnHtmlStatusPlayChanged
;
StatusPauseChanged
-=
OnHtmlStatusPauseChanged
;
SourceFailed
-=
OnHtmlSourceFailed
;
SourceSuspend
-=
OnHtmlSourceSuspend
;
SourceEnded
-=
OnHtmlSourceEnded
;
MetadataLoaded
-=
OnHtmlMetadataLoaded
;
TimeUpdated
-=
OnHtmlTimeUpdated
;
...
...
@@ -297,6 +300,23 @@ internal partial class HtmlMediaPlayer : Border
}
}
/// <summary>
/// Occurs when there is an Suspend associated with video. To fix the autoplay validation
/// </summary>
event
EventHandler
<
HtmlCustomEventArgs
>
SourceSuspend
{
add
{
_htmlVideo
.
RegisterHtmlCustomEventHandler
(
"suspend"
,
value
,
isDetailJson
:
false
);
_htmlAudio
.
RegisterHtmlCustomEventHandler
(
"suspend"
,
value
,
isDetailJson
:
false
);
}
remove
{
_htmlVideo
.
UnregisterHtmlCustomEventHandler
(
"suspend"
,
value
);
_htmlAudio
.
UnregisterHtmlCustomEventHandler
(
"suspend"
,
value
);
}
}
private
void
OnHtmlTimeUpdated
(
object
sender
,
EventArgs
e
)
{
OnTimeUpdate
?.
Invoke
(
this
,
EventArgs
.
Empty
);
...
...
@@ -345,6 +365,7 @@ internal partial class HtmlMediaPlayer : Border
Duration
=
NativeMethods
.
GetDuration
(
_activeElement
.
HtmlId
);
}
OnSourceLoaded
?.
Invoke
(
this
,
EventArgs
.
Empty
);
OnStatusChanged
?.
Invoke
(
this
,
EventArgs
.
Empty
);
}
private
void
OnHtmlStatusPlayChanged
(
object
sender
,
EventArgs
e
)
...
...
@@ -368,9 +389,27 @@ internal partial class HtmlMediaPlayer : Border
OnStatusChanged
?.
Invoke
(
this
,
EventArgs
.
Empty
);
}
private
void
OnHtmlSourceSuspend
(
object
sender
,
HtmlCustomEventArgs
e
)
{
if
(
this
.
Log
().
IsEnabled
(
Uno
.
Foundation
.
Logging
.
LogLevel
.
Debug
))
{
this
.
Log
().
Error
(
$"
{
_activeElementName
}
source Suspend: [
{
Source
}
]"
);
}
if
(
_activeElement
!=
null
)
{
IsPause
=
NativeMethods
.
GetPaused
(
_activeElement
.
HtmlId
);
}
if
(
IsPause
)
{
IsPause
=
true
;
_isPlaying
=
false
;
OnStatusChanged
?.
Invoke
(
this
,
EventArgs
.
Empty
);
}
}
private
void
OnHtmlSourceFailed
(
object
sender
,
HtmlCustomEventArgs
e
)
{
TimeUpdated
+
=
OnHtmlTimeUpdated
;
TimeUpdated
-
=
OnHtmlTimeUpdated
;
if
(
_activeElement
!=
null
)
{
_activeElement
.
SetCssStyle
(
"visibility"
,
"hidden"
);
...
...
@@ -379,6 +418,7 @@ internal partial class HtmlMediaPlayer : Border
{
this
.
Log
().
Error
(
$"
{
_activeElementName
}
source failed: [
{
Source
}
]"
);
}
IsPause
=
true
;
OnSourceFailed
?.
Invoke
(
this
,
e
.
Detail
);
}
...
...
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.d.ts
浏览文件 @
efe20c33
...
...
@@ -3,6 +3,7 @@ declare namespace Uno.UI.Media {
static
videoWidth
(
htmlId
:
number
):
number
;
static
videoHeight
(
htmlId
:
number
):
number
;
static
getCurrentPosition
(
htmlId
:
number
):
number
;
static
getPaused
(
htmlId
:
number
):
number
;
static
setCurrentPosition
(
htmlId
:
number
,
currentTime
:
number
):
void
;
static
setAttribute
(
htmlId
:
number
,
name
:
string
,
value
:
string
):
void
;
static
removeAttribute
(
htmlId
:
number
,
name
:
string
):
void
;
...
...
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/WasmScripts/uno.ui.media.js
浏览文件 @
efe20c33
...
...
@@ -15,6 +15,9 @@ var Uno;
static
getCurrentPosition
(
htmlId
)
{
return
document
.
getElementById
(
htmlId
.
toString
()).
currentTime
;
}
static
getPaused
(
htmlId
)
{
return
document
.
getElementById
(
htmlId
.
toString
()).
paused
;
}
static
setCurrentPosition
(
htmlId
,
currentTime
)
{
document
.
getElementById
(
htmlId
.
toString
()).
currentTime
=
currentTime
;
}
...
...
src/AddIns/Uno.UI.MediaPlayer.WebAssembly/ts/MediaElement.ts
浏览文件 @
efe20c33
...
...
@@ -13,6 +13,10 @@ namespace Uno.UI.Media {
return
document
.
getElementById
(
htmlId
.
toString
()).
currentTime
;
}
public
static
getPaused
(
htmlId
:
number
):
number
{
return
document
.
getElementById
(
htmlId
.
toString
()).
paused
;
}
public
static
setCurrentPosition
(
htmlId
:
number
,
currentTime
:
number
)
{
document
.
getElementById
(
htmlId
.
toString
()).
currentTime
=
currentTime
;
}
...
...
src/Uno.UI/UI/Xaml/Controls/MediaPlayerElement/MediaTransportControls.MediaPlayer.cs
浏览文件 @
efe20c33
...
...
@@ -320,7 +320,7 @@ namespace Windows.UI.Xaml.Controls
private
void
OnPointerExited
(
object
sender
,
PointerRoutedEventArgs
e
)
{
_isScrubbing
=
false
;
if
(
_wasPlaying
)
if
(
_wasPlaying
&&
_mediaPlayer
!=
null
&&
!
_mediaPlayer
.
PlaybackSession
.
IsPlaying
)
{
_mediaPlayer
?.
Play
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录