You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can technically inherit from the Player component, but one cannot instantiate it properly, as far as I know.
It would be convenient if the fourth optional argument of the videojs would be a class to instantiate from.
Would be very convenient as an alternative to plugins to change player's behaviour.
I can PR the bellow code if you find it useful.
Snippet
NB : dunno if this snippet works with the Player.extend way of inheriting.
/** * Doubles as the main function for users to create a player instance and also * the main library object. * The `videojs` function can be used to initialize or retrieve a player. * ```js * var myPlayer = videojs('my_video_id'); * ``` * * @param {String|Element} id Video element or video element ID * @param {Object=} options Optional options object for config/settings * @param {Function=} ready Optional ready callback * @param {Function=} PlayerClass Optional, the constructor of a class inheriting from Player * @return {Player} A player instance * @mixes videojs * @method videojs */letvideojs=function(id,options,ready,PlayerClass=Player){if(!PlayerClass.prototypeinstanceofPlayer&&!PlayerClass===Player){thrownewTypeError('PlayerClass argument must the constructor of a class inheriting from Player, or the Player class itself.');}// ... // Element may have a player attr referring to an already created player instance.// If not, set up a new player and return the instance.returntag['player']||Player.players[tag.playerId]||newPlayerClass(tag,options,ready);}
The text was updated successfully, but these errors were encountered:
If you already have a player, why not just create a new instance of it yourself? The videojs function is basically so that you don't need to create the player manually.
@adam187 @sveinburne can you elaborate on the use-case? Why is it necessary over just having you create the Player manually yourself, since you already have a reference to it?
Description
One can technically inherit from the Player component, but one cannot instantiate it properly, as far as I know.
It would be convenient if the fourth optional argument of the
videojs
would be a class to instantiate from.Would be very convenient as an alternative to plugins to change player's behaviour.
I can PR the bellow code if you find it useful.
Snippet
NB : dunno if this snippet works with the
Player.extend
way of inheriting.The text was updated successfully, but these errors were encountered: