From 8b17fae03150e058bb383cb24db41d65ca5ac185 Mon Sep 17 00:00:00 2001 From: Rafael Rosa Date: Fri, 16 Jun 2023 14:16:48 -0300 Subject: [PATCH] chore: remove Suspended and use the SourceLoaded --- .../HtmlMediaPlayer.cs | 40 ++----------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs b/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs index 6082d0cad1..ca7ad74191 100644 --- a/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs +++ b/src/AddIns/Uno.UI.MediaPlayer.WebAssembly/HtmlMediaPlayer.cs @@ -69,7 +69,6 @@ internal partial class HtmlMediaPlayer : Border StatusPlayChanged += OnHtmlStatusPlayChanged; StatusPauseChanged += OnHtmlStatusPauseChanged; SourceFailed += OnHtmlSourceFailed; - SourceSuspend += OnHtmlSourceSuspend; SourceEnded += OnHtmlSourceEnded; MetadataLoaded += OnHtmlMetadataLoaded; @@ -86,7 +85,6 @@ internal partial class HtmlMediaPlayer : Border StatusPlayChanged -= OnHtmlStatusPlayChanged; StatusPauseChanged -= OnHtmlStatusPauseChanged; SourceFailed -= OnHtmlSourceFailed; - SourceSuspend -= OnHtmlSourceSuspend; SourceEnded -= OnHtmlSourceEnded; MetadataLoaded -= OnHtmlMetadataLoaded; TimeUpdated -= OnHtmlTimeUpdated; @@ -300,23 +298,6 @@ internal partial class HtmlMediaPlayer : Border } } - /// - /// Occurs when there is an Suspend associated with video. To fix the autoplay validation - /// - event EventHandler 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); @@ -365,6 +346,9 @@ internal partial class HtmlMediaPlayer : Border Duration = NativeMethods.GetDuration(_activeElement.HtmlId); } OnSourceLoaded?.Invoke(this, EventArgs.Empty); + + IsPause = NativeMethods.GetPaused(_activeElement.HtmlId); + _isPlaying = !IsPause; OnStatusChanged?.Invoke(this, EventArgs.Empty); } @@ -389,24 +373,6 @@ 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; -- GitLab