Video.js: Do we want to support three different ways to watch a `ready` event in Player?

Created on 14 Nov 2016  路  9Comments  路  Source: videojs/video.js

Description

There are three ways to check for a player ready event, are we sure that we want to have three ways rather than just 1?

Pass a callback to the videojs() function as a third argument:

// Passing `null` for the options argument.
videojs('my-player', null, function() {
  this.addClass('my-example');
});

Pass a callback to a player's ready() method:

var player = videojs('my-player');

player.ready(function() {
  this.addClass('my-example');
});

Listen for the player's "ready" event:

var player = videojs('my-player');

player.on('ready', function() {
  this.addClass('my-example');
});

Most helpful comment

player.ready() triggers the function if the player is already ready. on('ready'... does not.

All 9 comments

I think the only real candidate for removal would be the player.ready function. I can't think of any other event that has a special method to add a listener like that.

player.ready() triggers the function if the player is already ready. on('ready'... does not.

Good point.

Ok with that in mind I guess it does make sense to keep all three of these unless we want to remove the ready function argument from videojs().

... or get rid of ready altogether.

How would that be possible @dmlap?

I think we're not ready to remove ready :D

Maybe we should abstract ready away from users and wrap our own methods in ready calls. We would just need to make sure that ready calls things in order.

Whether we abstract it away, I don't think we want to remove it's functionality.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onigetoc picture onigetoc  路  4Comments

uikoo9 picture uikoo9  路  4Comments

jeonghwaYoo picture jeonghwaYoo  路  3Comments

shivamg705 picture shivamg705  路  4Comments

SolmazKh picture SolmazKh  路  4Comments