From fa20223c4498e72bd13b87b05c0297b544c4724b Mon Sep 17 00:00:00 2001 From: Lyqqt Date: Wed, 12 Mar 2025 21:14:23 +0800 Subject: [PATCH] fix(windows): event name not matches with SPEC (#4455) --- windows/ReactNativeVideoCPP/ReactVideoView.cpp | 10 +++++----- windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/windows/ReactNativeVideoCPP/ReactVideoView.cpp b/windows/ReactNativeVideoCPP/ReactVideoView.cpp index cd2e7af3..bb0c71ba 100644 --- a/windows/ReactNativeVideoCPP/ReactVideoView.cpp +++ b/windows/ReactNativeVideoCPP/ReactVideoView.cpp @@ -75,7 +75,7 @@ ReactVideoView::ReactVideoView(winrt::Microsoft::ReactNative::IReactContext cons auto currentTimeInSeconds = mediaPlayer.PlaybackSession().Position().count() / 10000000; self->m_reactContext.DispatchEvent( *self, - L"topProgress", + L"topVideoProgress", [&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept { eventDataWriter.WriteObjectBegin(); { @@ -102,7 +102,7 @@ void ReactVideoView::OnMediaOpened(IInspectable const &, IInspectable const &) { strong_this->m_reactContext.DispatchEvent( *strong_this, - L"topLoad", + L"topVideoLoad", [&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept { eventDataWriter.WriteObjectBegin(); { @@ -135,7 +135,7 @@ void ReactVideoView::OnMediaOpened(IInspectable const &, IInspectable const &) { void ReactVideoView::OnMediaFailed(IInspectable const &, IInspectable const &) { runOnQueue([weak_this{get_weak()}]() { if (auto strong_this{weak_this.get()}) { - strong_this->m_reactContext.DispatchEvent(*strong_this, L"topError", nullptr); + strong_this->m_reactContext.DispatchEvent(*strong_this, L"topVideoError", nullptr); } }); } @@ -143,7 +143,7 @@ void ReactVideoView::OnMediaFailed(IInspectable const &, IInspectable const &) { void ReactVideoView::OnMediaEnded(IInspectable const &, IInspectable const &) { runOnQueue([weak_this{get_weak()}]() { if (auto strong_this{weak_this.get()}) { - strong_this->m_reactContext.DispatchEvent(*strong_this, L"topEnd", nullptr); + strong_this->m_reactContext.DispatchEvent(*strong_this, L"topVideoEnd", nullptr); } }); } @@ -155,7 +155,7 @@ void ReactVideoView::OnBufferingEnded(IInspectable const &, IInspectable const & void ReactVideoView::OnSeekCompleted(IInspectable const &, IInspectable const &) { runOnQueue([weak_this{get_weak()}]() { if (auto strong_this{weak_this.get()}) { - strong_this->m_reactContext.DispatchEvent(*strong_this, L"topSeek", nullptr); + strong_this->m_reactContext.DispatchEvent(*strong_this, L"topVideoSeek", nullptr); } }); } diff --git a/windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp b/windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp index c17b2528..12a6cd45 100644 --- a/windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp +++ b/windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp @@ -112,10 +112,11 @@ ConstantProviderDelegate ReactVideoViewManager::ExportedCustomBubblingEventTypeC ConstantProviderDelegate ReactVideoViewManager::ExportedCustomDirectEventTypeConstants() noexcept { return [](winrt::Microsoft::ReactNative::IJSValueWriter const &constantWriter) { - WriteCustomDirectEventTypeConstant(constantWriter, "Load"); - WriteCustomDirectEventTypeConstant(constantWriter, "End"); - WriteCustomDirectEventTypeConstant(constantWriter, "Seek"); - WriteCustomDirectEventTypeConstant(constantWriter, "Progress"); + WriteCustomDirectEventTypeConstant(constantWriter, "VideoLoad"); + WriteCustomDirectEventTypeConstant(constantWriter, "VideoEnd"); + WriteCustomDirectEventTypeConstant(constantWriter, "VideoSeek"); + WriteCustomDirectEventTypeConstant(constantWriter, "VideoProgress"); + WriteCustomDirectEventTypeConstant(constantWriter, "VideoError"); }; }