fix(windows): event name not matches with SPEC (#4455)

This commit is contained in:
Lyqqt
2025-03-12 21:14:23 +08:00
committed by GitHub
parent 6e6f91517c
commit fa20223c44
2 changed files with 10 additions and 9 deletions

View File

@@ -75,7 +75,7 @@ ReactVideoView::ReactVideoView(winrt::Microsoft::ReactNative::IReactContext cons
auto currentTimeInSeconds = mediaPlayer.PlaybackSession().Position().count() / 10000000; auto currentTimeInSeconds = mediaPlayer.PlaybackSession().Position().count() / 10000000;
self->m_reactContext.DispatchEvent( self->m_reactContext.DispatchEvent(
*self, *self,
L"topProgress", L"topVideoProgress",
[&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept { [&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept {
eventDataWriter.WriteObjectBegin(); eventDataWriter.WriteObjectBegin();
{ {
@@ -102,7 +102,7 @@ void ReactVideoView::OnMediaOpened(IInspectable const &, IInspectable const &) {
strong_this->m_reactContext.DispatchEvent( strong_this->m_reactContext.DispatchEvent(
*strong_this, *strong_this,
L"topLoad", L"topVideoLoad",
[&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept { [&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept {
eventDataWriter.WriteObjectBegin(); eventDataWriter.WriteObjectBegin();
{ {
@@ -135,7 +135,7 @@ void ReactVideoView::OnMediaOpened(IInspectable const &, IInspectable const &) {
void ReactVideoView::OnMediaFailed(IInspectable const &, IInspectable const &) { void ReactVideoView::OnMediaFailed(IInspectable const &, IInspectable const &) {
runOnQueue([weak_this{get_weak()}]() { runOnQueue([weak_this{get_weak()}]() {
if (auto strong_this{weak_this.get()}) { 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 &) { void ReactVideoView::OnMediaEnded(IInspectable const &, IInspectable const &) {
runOnQueue([weak_this{get_weak()}]() { runOnQueue([weak_this{get_weak()}]() {
if (auto strong_this{weak_this.get()}) { 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 &) { void ReactVideoView::OnSeekCompleted(IInspectable const &, IInspectable const &) {
runOnQueue([weak_this{get_weak()}]() { runOnQueue([weak_this{get_weak()}]() {
if (auto strong_this{weak_this.get()}) { 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);
} }
}); });
} }

View File

@@ -112,10 +112,11 @@ ConstantProviderDelegate ReactVideoViewManager::ExportedCustomBubblingEventTypeC
ConstantProviderDelegate ReactVideoViewManager::ExportedCustomDirectEventTypeConstants() noexcept { ConstantProviderDelegate ReactVideoViewManager::ExportedCustomDirectEventTypeConstants() noexcept {
return [](winrt::Microsoft::ReactNative::IJSValueWriter const &constantWriter) { return [](winrt::Microsoft::ReactNative::IJSValueWriter const &constantWriter) {
WriteCustomDirectEventTypeConstant(constantWriter, "Load"); WriteCustomDirectEventTypeConstant(constantWriter, "VideoLoad");
WriteCustomDirectEventTypeConstant(constantWriter, "End"); WriteCustomDirectEventTypeConstant(constantWriter, "VideoEnd");
WriteCustomDirectEventTypeConstant(constantWriter, "Seek"); WriteCustomDirectEventTypeConstant(constantWriter, "VideoSeek");
WriteCustomDirectEventTypeConstant(constantWriter, "Progress"); WriteCustomDirectEventTypeConstant(constantWriter, "VideoProgress");
WriteCustomDirectEventTypeConstant(constantWriter, "VideoError");
}; };
} }