-
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
Possible incorrect logic with registering new Player #8925
Comments
👋 Thanks for opening your first issue here! 👋 If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. |
Yes, I think you're correct that that should be a some and not every. Care to submit a PR? (Ideally, with a new test for it. Can use this as a template https://github.com/videojs/video.js/blob/main/test/unit/player.test.js#L2328-L2346) Thanks! |
Sure, but I wanted to ask about what is the reason of this limitation? |
It's to try and make sure that all player instances on the page use the same player component. The idea being that if there are players that aren't the same player component, there may end up issues around it. |
Yeah, I understand what this check is doing, I don't understand why :) |
Yes, this error is a bit theoretical. But, we essentially never want to get an issue opened because a user initialized a player, set a new player component, and then initialized a new player. Being able to override the player component is itself a pretty new capability. It used to be explicitly disallowed, I believe. I think the thought is that if someone is iterating through all the players, which hooks in video.js do, it's possible that different player components may or may not have the same functionality. So, you may break if you're expecting a method, but it isn't available on all instances. |
Can I ask what you're using the custom player for? And what issue did you encounter that you hit this block? Maybe there are alternatives. |
We are making our own interface for the player, using video.js component system. Partly it is base components, partly — our own components, which extends base components. And they are packed in a completely different layout, than base one. We used to draw an external UI layer on top of the video.js, which hooks on actions and events from the player, but when the player itself gives us such a rich extending capabilities, we decided that it might be easier to make an UI using "native" video.js components. And as long as Player itself is a component, and when I saw, that video.js gets a Player class from the DI upon creating player — we made a subclass for it as well. And we are replacing base Player class with our subclass. For now all it does — adds a custom CSS classes from And then I've added possibility to use different classes, if needed, effectively replacing Player component in DI before creating player. This is the moment when I hit this limitation from the topic start. Actually we don't use (and don't plan to use) different classes for players, just this one single subclass I mentioned earlier. And also we don't have pages in the app, where two or more players coexists. So, this is not a big deal and I can remove this feature easily from our codebase, so this question is basically was out of curiosity. Because I tried to create several players, each one based on a different class, on the single page, during the tests, and didn't see an issue. But I understand precaution now, from your explanation about methods, which might be absent or with different behavior. |
I'm not sure, but shouldn't there be
some
instead ofevery
?"If at least one player is not disposed yet"
video.js/src/js/component.js
Lines 2024 to 2032 in 62f3844
The text was updated successfully, but these errors were encountered: