-
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
execution order of plugins initialization & player initialize callback function #2505
Comments
This looks like it is a bug in 4.x, but there is very little chance we're going to put out a patch to fix this in 4.12. The easiest workaround would me to call your function in your ready block instead of using options to initialize: var player = videojs('player', {}, function() {
this.my_plugin();
this.my_func();
}); I was hoping this had been fixed in 5.0 already, but it looks like we've got a new issue to fix regarding plugin initialization via an options object. So basically, same workaround required in master right now, but we're working on it. All of this being said, if you're planning on releasing this plugin into the wild, please add things to the videojs prototype with extreme caution. There's the simple case of two plugins potentially overwriting each other, but we also try to subscribe to the "don't modify objects you don't own" philosophy, so generally we suggest adding new methods under your plugin rather than directly to vjs. Feel free to totally ignore all of that if you plan on keeping this plugin to yourself; this is more applicable if you plan on releasing the plugin publicly. |
I initially accidentally closed this, but I think #2510 probably covers this in terms of tracking. Closing this in lieu of that issue, but feel free to continue the conversation here or there. |
I see. Thank you very much. |
videojs version: 4.11
I wanna make a plugin. The plugin will attach a function to the player which get initialized. Then I wanna be able to call the attached function in the player initialize callback function.
If the tech is
flash
,this.my_func()
will get executed well. However if the tech ishtml5
, it throws error saying that the function is not defined.Further investigation tells me that in
flash
mode, the plugin get initialized before the callback function runs. While inhtml5
mode, the callback function get executed before the plugin initialization.Looks like the behaviour is inconsistent across flash and html5. Or am I doing something wrong?
Any workaround would also be great.
Thanks
The text was updated successfully, but these errors were encountered: