Skip to content

fix: prevent Wistia crash when src changes while playing#2041

Open
Malaybhai11 wants to merge 1 commit into
cookpete:masterfrom
Malaybhai11:fix/wistia-src-change-crash
Open

fix: prevent Wistia crash when src changes while playing#2041
Malaybhai11 wants to merge 1 commit into
cookpete:masterfrom
Malaybhai11:fix/wistia-src-change-crash

Conversation

@Malaybhai11

Copy link
Copy Markdown

Problem

After upgrading from v2.16.1 to v3.3.3, switching the video source while playing causes a Wistia player crash (fixes #2000).

Root Cause

In Player.tsx, the underlying player component (including wistia-video-element) is not re-mounted when src changes. The Wistia custom element keeps internal state (the old player instance) that becomes stale/inconsistent when a new source is set while the previous video is still playing, leading to a crash.

Fix

Added key={props.src} to the Player component in Player.tsx. This forces React to fully unmount and remount the player element whenever the src prop changes, ensuring the old Wistia player instance is properly destroyed before a new one is created.

This is a one-line change that applies to all player types, providing consistent and safe source-change behavior across Wistia, YouTube, Vimeo, and other providers.

Changes

  • src/Player.tsx: Added key={props.src} prop to the Player element

Add a key prop based on src to the Player component to force a
complete remount when the video source changes. This ensures the old
Wistia player instance is properly destroyed before creating a new
one, preventing crashes that occur when switching sources while playing.

Fixes cookpete#2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wistia player crashes when src changes while playing

1 participant