From f7b0653b9afa11a98a010adc2d7a5e90a360893a Mon Sep 17 00:00:00 2001 From: Louis Lagrange Date: Wed, 21 Apr 2021 16:12:19 +0800 Subject: [PATCH] Add onPlayerInitialized prop To retrieve player instance --- src/player-prop-types.js | 1 + src/react-jw-player.jsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/player-prop-types.js b/src/player-prop-types.js index de82be6f..4e465ac6 100644 --- a/src/player-prop-types.js +++ b/src/player-prop-types.js @@ -25,6 +25,7 @@ const propTypes = { onOneHundredPercent: PropTypes.func, onPause: PropTypes.func, onPlay: PropTypes.func, + onPlayerInitialized: PropTypes.func, onReady: PropTypes.func, onResume: PropTypes.func, onSeventyFivePercent: PropTypes.func, diff --git a/src/react-jw-player.jsx b/src/react-jw-player.jsx index b458a273..7b37bf4f 100644 --- a/src/react-jw-player.jsx +++ b/src/react-jw-player.jsx @@ -74,7 +74,7 @@ class ReactJWPlayer extends Component { removeJWPlayerInstance(this.videoRef, window); } _initialize() { - const { playerId, useMultiplePlayerScripts } = this.props; + const { playerId, useMultiplePlayerScripts, onPlayerInitialized } = this.props; if (useMultiplePlayerScripts) { setJWPlayerDefaults({ context: window, playerId }); @@ -90,6 +90,10 @@ class ReactJWPlayer extends Component { const playerOpts = getPlayerOpts(this.props); initialize({ component, player, playerOpts }); + + if (onPlayerInitialized) { + onPlayerInitialized(player); + } } _setVideoRef(element) { this.videoRef = element;