This commit is contained in:
@@ -48,7 +48,7 @@ export default {
|
||||
duration: 0,
|
||||
progress: 0,
|
||||
intervalProgress: 0,
|
||||
intervalHistory: 0,
|
||||
intervalState: 0,
|
||||
preConvert: false,
|
||||
};
|
||||
},
|
||||
@@ -68,25 +68,27 @@ export default {
|
||||
this.audio.pause();
|
||||
|
||||
window.clearInterval(this.intervalProgress);
|
||||
window.clearInterval(this.intervalHistory);
|
||||
window.clearInterval(this.intervalState);
|
||||
|
||||
this.progress = this.audio.currentTime;
|
||||
this.pushState();
|
||||
},
|
||||
durationChanged() {
|
||||
this.duration = this.audio.duration;
|
||||
},
|
||||
playing() {
|
||||
window.clearInterval(this.intervalProgress);
|
||||
window.clearInterval(this.intervalHistory);
|
||||
window.clearInterval(this.intervalState);
|
||||
|
||||
this.intervalProgress = setInterval(() => {
|
||||
this.progress = this.audio.currentTime;
|
||||
this.selectedTrack.percent = (100 / this.duration) * this.progress;
|
||||
}, 500);
|
||||
|
||||
this.intervalHistory = setInterval(() => {
|
||||
console.log(this.selectedTrack);
|
||||
}, 10000);
|
||||
if (this.currentUser._id) {
|
||||
this.intervalState = setInterval(() => {
|
||||
this.pushState();
|
||||
}, 10000);
|
||||
}
|
||||
},
|
||||
audioReset() {
|
||||
this.audio.pause();
|
||||
@@ -107,6 +109,14 @@ export default {
|
||||
this.audio.play();
|
||||
}
|
||||
},
|
||||
skipToSecond(second) {
|
||||
let was_paused = this.audio.paused;
|
||||
this.audio.pause();
|
||||
this.audio.currentTime = second;
|
||||
if (!was_paused) {
|
||||
this.audio.play();
|
||||
}
|
||||
},
|
||||
playRadio(radio) {
|
||||
this.$store.commit("tracks/resetSelectedTrack");
|
||||
this.audio.pause();
|
||||
@@ -135,8 +145,12 @@ export default {
|
||||
|
||||
this.pushHistoryItem();
|
||||
|
||||
// Try to fix SAFARI
|
||||
this.audio.play();
|
||||
if (this.selectedTrack.parent.progress) {
|
||||
this.skipToSecond(this.selectedTrack.parent.progress.progress);
|
||||
} else {
|
||||
// Try to fix SAFARI
|
||||
this.audio.play();
|
||||
}
|
||||
},
|
||||
pushHistoryItem() {
|
||||
if (!this.currentUser._id) {
|
||||
@@ -190,7 +204,7 @@ export default {
|
||||
},
|
||||
reset() {
|
||||
window.clearInterval(this.intervalProgress);
|
||||
window.clearInterval(this.intervalHistory);
|
||||
window.clearInterval(this.intervalState);
|
||||
if (!this.audio.paused) {
|
||||
this.audio.pause();
|
||||
}
|
||||
@@ -251,6 +265,19 @@ export default {
|
||||
}
|
||||
this.$store.dispatch("user/savePlayerSettings");
|
||||
},
|
||||
pushState() {
|
||||
if (!this.currentUser._id) {
|
||||
return;
|
||||
}
|
||||
this.progress = this.audio.currentTime;
|
||||
let item = {
|
||||
id: this.selectedTrack._id,
|
||||
parentId: this.selectedTrack.parent._id,
|
||||
type: "track",
|
||||
progress: Math.round(this.progress)
|
||||
}
|
||||
this.$store.dispatch("user/saveProgress", item);
|
||||
},
|
||||
timeUpdate(event) {
|
||||
let percent = (event.target.currentTime / event.target.duration) * 100;
|
||||
if (percent > 10 && !this.preConvert) {
|
||||
|
||||
Reference in New Issue
Block a user