-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Warn if options / ready function are passed to a previously created player instance #1730
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,15 @@ var vjs = function(id, options, ready){ | |
|
||
// If a player instance has already been created for this ID return it. | ||
if (vjs.players[id]) { | ||
|
||
// If options or ready funtion are passed, warn | ||
if (options) { | ||
vjs.log.warn ('Player "' + id + '" is already initialised. Options will not be applied.'); | ||
} | ||
if (ready) { | ||
vjs.log.warn ('Player "' + id + '" is already initialised. Ready function will not be executed.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I think we can actually still use the player's ready function.
The ready function has a feature where if ready as already fired, it will immediately execute the function passed to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to make that be asynchronous rather than calling it sync in the case of ready already happening. Otherwise, it's good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok cool, feel free to add that to the other issue. |
||
} | ||
|
||
return vjs.players[id]; | ||
|
||
// Otherwise get element for ID | ||
|
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 wonder if we couldn't still handle options and update the values in this case. Though handling options like children after init would get super complicated, so probably not.
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.
Deep merging is hard. But otherwise, yes, it could happen.