-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use explicit isReady property to guard player methods
Fixes #18
- Loading branch information
Showing
4 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next step is to queue these method calls and execute them once the SDK ready callback fires. Maybe we could wrap everything in a new
this.onReady
method?Right now I'm thinking my initial calls to
setVolume
will fail, and the player will initialize with the incorrect volume set.ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Volume should be fine, as the volume is already set when players become ready, but this is not the case for seeking. Perhaps we could set
this.seekOnReady
in the method if!this.isReady
, then whenonReady
is called, check to see ifseekOnReady
is set, andseekTo
if so..ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it gets a little weird. I'm not sure i'd always want the command to go through if the SDK loads like ~2 seconds later...
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to be an issue.
this.player.playVideo
isn't available after theonReady
for some reason. I'll keep looking into it.ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be interested to know how this is happening considering it should be the player itself that causes
onReady
to fire 😕ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only happens when I immediately load a video and try to play it. Maybe there's some kind of race condition where the API methods don't exist while a video is being loaded?
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I really know is, inside
onReady
this.player.playVideo
is a function, but then whenplay
is executed, it isn't.this.player
is still a YouTube player API instance, but the method just doesn't exist at that exact moment.ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I'm just going to make a custom build of this that sanity checks the method before attempting to call it. I'm not sure how you want to handle this in the official build, though.
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to sanity check methods for now. I'll publish a patch and create a issue to follow up.
ef17dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
v0.3.3
and I've opened #20 to follow it up.