-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prime players to enable autoplay when out of focus #13
Conversation
* Allows us to render the Vimeo player without a valid URL, which helps us fix bugs * More or less reverts commit d308aa6
d4b6b2b
to
724ea09
Compare
I was thinking of making the priming functionality manual by using a configuration parameter: const reactPlayerProps = {
youtubeConfig: {
preload: true
},
vimeoConfig: {
preload: true
}
};
<ReactPlayer {...reactPlayerProps} /> This way we could avoid loading those APIs for those who don't intend on using them. |
Updated. Moved priming logic from |
Updated. Now using slightly less ambiguous |
Updated (again) with a short explanation in |
Looking to merge this soon even if it's a bit weird.. @Fauntleroy are you happy enough? |
@cookpete I'll take a look at this soon to ensure that it works properly. My initial test earlier this week was having some problems. Can you check and see if |
Ah yeah that should have been sorted by 52574f8 |
Something is definitely wrong when I try to use this in my application. I'm going to try a few things and see if I can resolve the problem. |
Autoplay seems to behave differently than it did before, but with Volume, however, is broken. Looks like you just need to make sure volume is included in shouldComponentUpdate (nextProps) {
return (
this.props.url !== nextProps.url ||
this.props.playing !== nextProps.playing ||
this.props.volume !== nextProps.volume
)
} |
I'm also running into |
The issue with progress = () => {
if (this.props.url && this.refs.player) {
let progress = {}
const loaded = this.refs.player.getFractionLoaded()
const played = this.refs.player.getFractionPlayed() |
I'm also having issues rendering all of the players inside my application. For some reason only YouTube will bother to render. Here's what my React inspector is showing me: I imagine something horrible is happening to important parts of the code when minification occurs. Maybe all of the component names are being destroyed, and that's causing a few things to break here and there? |
Wow, thanks very much @Fauntleroy for the testing! I've added some more fixups to hopefully solve most of the issues.
|
@cookpete it might not have to do with minification. I seem to remember being able to replicate the issue without minified code, but I can't remember exactly how that came about. I'll look into it more soon. |
I'm gonna merge this in an attempt to avoid conflicts with other fixes. Hopefully all problems (other than the weird minified issue) have been sorted |
* All players now need to update when url changes
* Now we're rendering all players at once, we don't want multiple progress loops going at once * Renamed `update` to `progress` – makes a bit more sense
11b589d
to
17fbef8
Compare
Prime players to enable autoplay when out of focus
My version of #12 that attempts to fix autoplay issues when
ReactPlayer
is not in a focused tab. In short:props
to the player that can play the currenturl
display: none
on itself ifurl
is not presentReactPlayer
mounts, ifYouTube
orVimeo
players don't have aurl
, thenprime
the player by playing a short, silent video whilst hidden. This allows the players to autoplay any URLs given later on, even if not in a focused tab.@Fauntleroy, any thoughts?