Skip to content
Snippets Groups Projects
Commit 56eaea3a authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed #10: now record track listens

parent 10efef52
Branches
No related tags found
No related merge requests found
import logger from '@/logging' import logger from '@/logging'
import cache from '@/cache' import cache from '@/cache'
import config from '@/config'
import Audio from '@/audio' import Audio from '@/audio'
import backend from '@/audio/backend' import backend from '@/audio/backend'
import radios from '@/radios' import radios from '@/radios'
import Vue from 'vue'
class Queue { class Queue {
constructor (options = {}) { constructor (options = {}) {
...@@ -176,6 +178,7 @@ class Queue { ...@@ -176,6 +178,7 @@ class Queue {
} }
handleAudioEnded (e) { handleAudioEnded (e) {
this.recordListen(this.currentTrack)
if (this.currentIndex < this.tracks.length - 1) { if (this.currentIndex < this.tracks.length - 1) {
logger.default.info('Audio track ended, playing next one') logger.default.info('Audio track ended, playing next one')
this.next() this.next()
...@@ -185,6 +188,14 @@ class Queue { ...@@ -185,6 +188,14 @@ class Queue {
} }
} }
recordListen (track) {
let url = config.API_URL + 'history/listenings/'
let resource = Vue.resource(url)
resource.save({}, {'track': track.id}).then((response) => {}, (response) => {
logger.default.error('Could not record track in history')
})
}
previous () { previous () {
if (this.currentIndex > 0) { if (this.currentIndex > 0) {
this.play(this.currentIndex - 1) this.play(this.currentIndex - 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment