diff --git a/public/config.json b/public/config.json index a3b7d4a..f966bb7 100644 --- a/public/config.json +++ b/public/config.json @@ -1,5 +1,5 @@ { - "backend_de": "http://localhost:31204", - "backend_dev": "https://webplay.rocks", + "backend_dev": "http://localhost:31204", + "backend_de": "https://webplay.rocks", "backend": "https://webplay.rocks" } \ No newline at end of file diff --git a/src/components/Player.vue b/src/components/Player.vue index fbbbd8f..5053261 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -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) { diff --git a/src/components/dialogs/AlbumViewer.vue b/src/components/dialogs/AlbumViewer.vue index 487f0c7..0e84074 100644 --- a/src/components/dialogs/AlbumViewer.vue +++ b/src/components/dialogs/AlbumViewer.vue @@ -1,25 +1,12 @@