Commit 56eaea3a authored by Agate's avatar Agate 💬

Fixed #10: now record track listens

parent 10efef52
import logger from '@/logging'
import cache from '@/cache'
import config from '@/config'
import Audio from '@/audio'
import backend from '@/audio/backend'
import radios from '@/radios'
import Vue from 'vue'
class Queue {
constructor (options = {}) {
......@@ -176,6 +178,7 @@ class Queue {
}
handleAudioEnded (e) {
this.recordListen(this.currentTrack)
if (this.currentIndex < this.tracks.length - 1) {
logger.default.info('Audio track ended, playing next one')
this.next()
......@@ -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 () {
if (this.currentIndex > 0) {
this.play(this.currentIndex - 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment