@@ -88,6 +88,14 @@ ReactVideoView::ReactVideoView(winrt::Microsoft::ReactNative::IReactContext cons
88
88
}
89
89
}
90
90
});
91
+
92
+ m_positionChangedToken = m_player.PlaybackSession ().PositionChanged (
93
+ winrt::auto_revoke, [ref = get_weak ()](auto const & sender, auto const & args) {
94
+ if (auto self = ref.get ()) {
95
+ auto newPosition = sender.Position ().count ();
96
+ self->m_mediaPlayerPosition = newPosition;
97
+ }
98
+ });
91
99
}
92
100
93
101
void ReactVideoView::OnMediaOpened (IInspectable const &, IInspectable const &) {
@@ -155,7 +163,22 @@ void ReactVideoView::OnBufferingEnded(IInspectable const &, IInspectable const &
155
163
void ReactVideoView::OnSeekCompleted (IInspectable const &, IInspectable const &) {
156
164
runOnQueue ([weak_this{get_weak ()}]() {
157
165
if (auto strong_this{weak_this.get ()}) {
158
- strong_this->m_reactContext .DispatchEvent (*strong_this, L" topVideoSeek" , nullptr );
166
+ if (auto mediaPlayer = strong_this->m_player ) {
167
+ auto currentTimeInSeconds = mediaPlayer.PlaybackSession ().Position ().count () / 10000000 ;
168
+ auto seekTimeInSeconds = strong_this->m_mediaPlayerPosition / 10000000 ;
169
+
170
+ strong_this->m_reactContext .DispatchEvent (
171
+ *strong_this,
172
+ L" topVideoSeek" ,
173
+ [&](winrt::Microsoft::ReactNative::IJSValueWriter const &eventDataWriter) noexcept {
174
+ eventDataWriter.WriteObjectBegin ();
175
+ {
176
+ WriteProperty (eventDataWriter, L" currentTime" , currentTimeInSeconds);
177
+ WriteProperty (eventDataWriter, L" seekTime" , seekTimeInSeconds);
178
+ }
179
+ eventDataWriter.WriteObjectEnd ();
180
+ });
181
+ }
159
182
}
160
183
});
161
184
}
0 commit comments