diff --git a/src/players/Base.js b/src/players/Base.js index 694af1ed..f49d16a2 100644 --- a/src/players/Base.js +++ b/src/players/Base.js @@ -38,7 +38,11 @@ export default class Base extends Component { if (this.props.playing || this.preloading) { this.preloading = false this.isReady = true - this.play() + if (this.loadOnReady) { + this.load(this.loadOnReady, this.props.playing) + } else { + this.play() + } } } } diff --git a/src/players/YouTube.js b/src/players/YouTube.js index b90a5e37..32ecfc2c 100644 --- a/src/players/YouTube.js +++ b/src/players/YouTube.js @@ -56,6 +56,11 @@ export default class YouTube extends Base { } return } + if (this.loadingSDK) { + this.loadOnReady = url + return + } + this.loadingSDK = true this.getSDK().then(YT => { this.player = new YT.Player(this.playerId, { width: '100%', @@ -66,7 +71,10 @@ export default class YouTube extends Base { ...this.props.youtubeConfig.playerVars }, events: { - onReady: this.onReady, + onReady: () => { + this.loadingSDK = false + this.onReady() + }, onStateChange: this.onStateChange, onError: this.props.onError }