Skip to content

Commit

Permalink
fix(iOS): fix reuse resource after enable Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Sep 18, 2024
1 parent 5cd9bbc commit 23b04ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ios/ReactNativeVideoPlayerView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ @interface ReactNativeVideoPlayerView () <RCTReactNativeVideoPlayerViewViewProto
@implementation ReactNativeVideoPlayerView {
#ifdef RCT_NEW_ARCH_ENABLED
UIView *_view;
BOOL _needReplay;
#else
RCTBridge *_bridge;
#endif
Expand Down Expand Up @@ -116,6 +117,12 @@ - (void)removeFromSuperview
#endif
}

- (void)prepareForRecycle
{
[_player pause];
_needReplay = YES;
}

- (void)_release
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down Expand Up @@ -317,6 +324,9 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
}
}
[self playItem:[Utils sourceToPlayItem:uri headers:headers]];
} else if (_needReplay) {
[self seekTo:0];
_needReplay = NO;
}

if (oldViewProps.paused != newViewProps.paused) {
Expand Down

0 comments on commit 23b04ef

Please sign in to comment.