const CounterDown = class {
constructor(count, callback) {
this.countFrom = count;
this.count = count;
this.callback = callback;
this.reset();
}
reset(count = 0) {
if (this.id) {
clearInterval(this.id);
}
this.count = count ? count : this.countFrom;
this.id = setInterval(() => { this._tick() }, 1000);
this.callback(this.count);
}
_tick() {
this.count -= 1;
if (this.count <= 0) {
clearInterval(this.id);
this.id = 0;
}
this.callback(this.count);
}
};
const counter = new CounterDown(10, count => { console.log(count); });
setTimeout(() => { counter.reset(5); }, 1500);
text/vtt
для vtt-файлов, как это делается зависит от web-сервераtext/plain
для субтитриов display:none;
оставить