add readyCallback

This commit is contained in:
Harvey committed 2022-04-21 17:49:12 +08:00
1 parent 92393357c7
commit 03fcc89abf
5 files changed
+22 -12

No files matched your search

+5 -1
View File
@@ -28,7 +28,7 @@ import Mobile from './mobile';
let id = 0;
const instances = [];
export default class Artplayer extends Emitter {
constructor(option) {
constructor(option, readyCallback) {
super();
this.id = ++id;
@@ -65,6 +65,10 @@ export default class Artplayer extends Emitter {
this.mobile = new Mobile(this);
}
if (typeof readyCallback === 'function') {
this.on('ready', () => readyCallback.call(this));
}
instances.push(this);
}