diff --git a/src/preload.js b/src/preload.js index 73ea6cd7..09fde3c0 100644 --- a/src/preload.js +++ b/src/preload.js @@ -19,6 +19,14 @@ const db = { getTrack: function(id) { return library.tracks[id] }, + addSkip: function(id) { + const track = db.getTrack(id) + if (!track.skipCount) track.skipCount = 0 + if (!track.skips) track.skips = [] + track.skipCount++ + track.skips.push(new Date().getTime()) + db.save() + }, getTrackPath: function(id, fileUrl) { const trackPath = path.join(tracksPath, db.getTrack(id).file) if (fileUrl) return pathToFileURL(trackPath) diff --git a/src/stores/player.js b/src/stores/player.js index f6571b33..e2cded80 100644 --- a/src/stores/player.js +++ b/src/stores/player.js @@ -1,5 +1,6 @@ import Gapless from 'gapless.js' import { writable } from 'svelte/store' +let library = db.get() export const currentTime = writable(0) export const duration = writable(0) @@ -21,6 +22,8 @@ export function previous() { gPlayer.playPrevious() } export function next() { + const currentId = gPlayer.currentTrack.metadata.id + db.addSkip(currentId) gPlayer.playNext() } export function playTrack(id) {