From 3d5a0c5476076f4bcc0cc9aff4f2d7fe753022c6 Mon Sep 17 00:00:00 2001 From: huayongxu Date: Fri, 26 Jun 2026 10:18:40 +0800 Subject: [PATCH] [NUI][API14] Add WebView APIs for video playback notification. Original-Author: yehyeon.kim@samsung.com Co-Authored-By: Cline SR --- .../src/internal/Interop/Interop.WebView.cs | 15 ++ src/Tizen.NUI/src/public/WebView/WebView.cs | 173 ++++++++++++++++++ 2 files changed, 188 insertions(+) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs index b689584ab74..99fab483868 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs @@ -381,6 +381,21 @@ internal static partial class WebView [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_SetVideoHole")] public static extern void SetVideoHole(HandleRef webViewRef, bool enable, bool isWaylandWindow); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterPlaybackVideoReadyCallback")] + public static extern void RegisterPlaybackVideoReadyCallback(HandleRef webViewRef, IntPtr callbackRef); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterPlaybackVideoStartedCallback")] + public static extern void RegisterPlaybackVideoStartedCallback(HandleRef webViewRef, IntPtr callbackRef); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterPlaybackVideoFinishedCallback")] + public static extern void RegisterPlaybackVideoFinishedCallback(HandleRef webViewRef, IntPtr callbackRef); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterPlaybackVideoStoppedCallback")] + public static extern void RegisterPlaybackVideoStoppedCallback(HandleRef webViewRef, IntPtr callbackRef); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterPlaybackVideoPausedCallback")] + public static extern void RegisterPlaybackVideoPausedCallback(HandleRef webViewRef, IntPtr callbackRef); } } } diff --git a/src/Tizen.NUI/src/public/WebView/WebView.cs b/src/Tizen.NUI/src/public/WebView/WebView.cs index f72309ff475..5349c05ae51 100755 --- a/src/Tizen.NUI/src/public/WebView/WebView.cs +++ b/src/Tizen.NUI/src/public/WebView/WebView.cs @@ -483,6 +483,24 @@ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef public delegate void WebViewDeviceListGetCallback(WebDeviceList list, int size); private WebViewDeviceListGetCallback deviceListGetCallbackForUser; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void WebViewPlaybackVideoCallback(); + + private EventHandler playbackVideoReadyEventHandler; + private WebViewPlaybackVideoCallback playbackVideoReadyCallback; + + private EventHandler playbackVideoStartedEventHandler; + private WebViewPlaybackVideoCallback playbackVideoStartedCallback; + + private EventHandler playbackVideoFinishedEventHandler; + private WebViewPlaybackVideoCallback playbackVideoFinishedCallback; + + private EventHandler playbackVideoStoppedEventHandler; + private WebViewPlaybackVideoCallback playbackVideoStoppedCallback; + + private EventHandler playbackVideoPausedEventHandler; + private WebViewPlaybackVideoCallback playbackVideoPausedCallback; + /// /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.
/// This signal is emitted when page loading has started.
@@ -3374,5 +3392,160 @@ private void OnDeviceConnectionChanged(int deviceType) deviceConnectionChangedEventHandler?.Invoke(this, new WebViewDeviceConnectionChangedEventArgs(deviceType)); } + /// + /// Event for the PlaybackVideoReady signal which can be used to subscribe or unsubscribe the event handler. + /// This signal is emitted when playback video is ready. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PlaybackVideoReady + { + add + { + if (playbackVideoReadyEventHandler == null) + { + playbackVideoReadyCallback = OnPlaybackVideoReady; + Interop.WebView.RegisterPlaybackVideoReadyCallback(SwigCPtr, Marshal.GetFunctionPointerForDelegate(playbackVideoReadyCallback)); + } + playbackVideoReadyEventHandler += value; + } + remove + { + playbackVideoReadyEventHandler -= value; + if (playbackVideoReadyEventHandler == null) + { + Interop.WebView.RegisterPlaybackVideoReadyCallback(SwigCPtr, IntPtr.Zero); + } + } + } + + /// + /// Event for the PlaybackVideoStarted signal which can be used to subscribe or unsubscribe the event handler. + /// This signal is emitted when playback video is started. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PlaybackVideoStarted + { + add + { + if (playbackVideoStartedEventHandler == null) + { + playbackVideoStartedCallback = OnPlaybackVideoStarted; + Interop.WebView.RegisterPlaybackVideoStartedCallback(SwigCPtr, Marshal.GetFunctionPointerForDelegate(playbackVideoStartedCallback)); + } + playbackVideoStartedEventHandler += value; + } + remove + { + playbackVideoStartedEventHandler -= value; + if (playbackVideoStartedEventHandler == null) + { + Interop.WebView.RegisterPlaybackVideoStartedCallback(SwigCPtr, IntPtr.Zero); + } + } + } + + /// + /// Event for the PlaybackVideoFinished signal which can be used to subscribe or unsubscribe the event handler. + /// This signal is emitted when playback video is finished. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PlaybackVideoFinished + { + add + { + if (playbackVideoFinishedEventHandler == null) + { + playbackVideoFinishedCallback = OnPlaybackVideoFinished; + Interop.WebView.RegisterPlaybackVideoFinishedCallback(SwigCPtr, Marshal.GetFunctionPointerForDelegate(playbackVideoFinishedCallback)); + } + playbackVideoFinishedEventHandler += value; + } + remove + { + playbackVideoFinishedEventHandler -= value; + if (playbackVideoFinishedEventHandler == null) + { + Interop.WebView.RegisterPlaybackVideoFinishedCallback(SwigCPtr, IntPtr.Zero); + } + } + } + + /// + /// Event for the PlaybackVideoStopped signal which can be used to subscribe or unsubscribe the event handler. + /// This signal is emitted when playback video is stopped. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PlaybackVideoStopped + { + add + { + if (playbackVideoStoppedEventHandler == null) + { + playbackVideoStoppedCallback = OnPlaybackVideoStopped; + Interop.WebView.RegisterPlaybackVideoStoppedCallback(SwigCPtr, Marshal.GetFunctionPointerForDelegate(playbackVideoStoppedCallback)); + } + playbackVideoStoppedEventHandler += value; + } + remove + { + playbackVideoStoppedEventHandler -= value; + if (playbackVideoStoppedEventHandler == null) + { + Interop.WebView.RegisterPlaybackVideoStoppedCallback(SwigCPtr, IntPtr.Zero); + } + } + } + + /// + /// Event for the PlaybackVideoPaused signal which can be used to subscribe or unsubscribe the event handler. + /// This signal is emitted when playback video is paused. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PlaybackVideoPaused + { + add + { + if (playbackVideoPausedEventHandler == null) + { + playbackVideoPausedCallback = OnPlaybackVideoPaused; + Interop.WebView.RegisterPlaybackVideoPausedCallback(SwigCPtr, Marshal.GetFunctionPointerForDelegate(playbackVideoPausedCallback)); + } + playbackVideoPausedEventHandler += value; + } + remove + { + playbackVideoPausedEventHandler -= value; + if (playbackVideoPausedEventHandler == null) + { + Interop.WebView.RegisterPlaybackVideoPausedCallback(SwigCPtr, IntPtr.Zero); + } + } + } + + private void OnPlaybackVideoReady() + { + playbackVideoReadyEventHandler?.Invoke(this, new EventArgs()); + } + + private void OnPlaybackVideoStarted() + { + playbackVideoStartedEventHandler?.Invoke(this, new EventArgs()); + } + + private void OnPlaybackVideoFinished() + { + playbackVideoFinishedEventHandler?.Invoke(this, new EventArgs()); + } + + private void OnPlaybackVideoStopped() + { + playbackVideoStoppedEventHandler?.Invoke(this, new EventArgs()); + } + + private void OnPlaybackVideoPaused() + { + playbackVideoPausedEventHandler?.Invoke(this, new EventArgs()); + } + } }