Skip to content

Commit fc1a04b

Browse files
committed
fix destroy
1 parent bada61d commit fc1a04b

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/js/player.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,8 @@ class APlayer {
446446
instances.splice(instances.indexOf(this), 1);
447447
this.pause();
448448
this.container.innerHTML = '';
449-
clearInterval(this.playedTime);
450-
for (const key in this) {
451-
if (this.hasOwnProperty(key)) {
452-
delete this[key];
453-
}
454-
}
449+
this.audio.src = '';
450+
this.timer.destroy();
455451
}
456452

457453
handlePlayPromise (callback) {

src/js/timer.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ class Timer {
2121
}
2222

2323
init () {
24-
for (let i = 0; i < this.types.length; i++) {
25-
const type = this.types[i];
26-
if (type !== 'fps') {
27-
this[`init${type}Checker`]();
28-
}
29-
}
24+
this.types.map((item) => {
25+
this[`init${item}Checker`]();
26+
return item;
27+
});
3028
}
3129

3230
initprogressChecker () {
@@ -79,8 +77,12 @@ class Timer {
7977
this[`enable${type}Checker`] = false;
8078
}
8179

82-
destroy (type) {
83-
this[`${type}Checker`] && clearInterval(this[`${type}Checker`]);
80+
destroy () {
81+
this.types.map((item) => {
82+
this[`enable${item}Checker`] = false;
83+
this[`${item}Checker`] && clearInterval(this[`${item}Checker`]);
84+
return item;
85+
});
8486
}
8587
}
8688

0 commit comments

Comments
 (0)