Skip to content

Commit

Permalink
Fix preloading
Browse files Browse the repository at this point in the history
Preload players were unmounting and remounting when media is loaded later, which doesn't play the media until browser refocus (which ruins the whole point of preloading)
Using an array (together with the `key` for each player) means the same player is used when something is loaded later
  • Loading branch information
cookpete committed Oct 24, 2017
1 parent abd2096 commit 6dd81ba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ export default class ReactPlayer extends Component {
const preloadPlayers = this.renderPreloadPlayers(url)
return (
<div ref={this.wrapperRef} style={{ ...style, width, height }} {...otherProps}>
{activePlayer}
{preloadPlayers}
{[ activePlayer, ...preloadPlayers ]}
</div>
)
}
Expand Down

0 comments on commit 6dd81ba

Please sign in to comment.