mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Scrobbler fix
This commit is contained in:
@@ -130,6 +130,7 @@ class Controller {
|
||||
this.alreadyScrobbled = false;
|
||||
|
||||
this.messageID = 0;
|
||||
this.lastMessage = 0;
|
||||
|
||||
this.update()
|
||||
}
|
||||
@@ -143,6 +144,13 @@ class Controller {
|
||||
|
||||
// an actual update message from the script has arrived
|
||||
playbackUpdate(request) {
|
||||
|
||||
if (request.time < self.lastMessage) {
|
||||
console.log("Got message out of order, discarding!")
|
||||
return
|
||||
}
|
||||
self.lastMessage = request.time
|
||||
|
||||
//console.log("Update message from our tab " + this.tabId + " (" + this.page + ")")
|
||||
if (request.type == "stopPlayback" && this.currentlyPlaying) {
|
||||
this.stopPlayback(request.artist,request.title);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
bar = document.querySelector("div[class*=PlayerControls]")
|
||||
if (bar == null) {
|
||||
console.log("Nothing playing right now!")
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",artist:"",title:""})
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",time:Math.floor(Date.now()),artist:"",title:""})
|
||||
exit()
|
||||
}
|
||||
|
||||
@@ -21,18 +21,11 @@ else {
|
||||
control = bar.querySelector("div[class*=PlayerControls-buttonGroupCenter] > button:nth-child(2)").getAttribute("title")
|
||||
if (control == "Play") {
|
||||
console.log("Not playing right now")
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",artist:artist,title:title})
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",time:Math.floor(Date.now()),artist:artist,title:title})
|
||||
//stopPlayback()
|
||||
}
|
||||
else if (control == "Pause") {
|
||||
console.log("Playing " + artist + " - " + title)
|
||||
chrome.runtime.sendMessage({type:"startPlayback",artist:artist,title:title,duration:durationSeconds})
|
||||
chrome.runtime.sendMessage({type:"startPlayback",time:Math.floor(Date.now()),artist:artist,title:title,duration:durationSeconds})
|
||||
//startPlayback(artist,title,durationSeconds)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
bar = document.querySelector("ytmusic-player-bar")
|
||||
if (bar == null) {
|
||||
console.log("Nothing playing right now!")
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",artist:"",title:""})
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",time:Math.floor(Date.now()),artist:"",title:""})
|
||||
exit()
|
||||
}
|
||||
|
||||
@@ -23,18 +23,11 @@ else {
|
||||
control = ctrl.querySelector("div > paper-icon-button[class*=play-pause-button]").getAttribute("title")
|
||||
if (control == "Play") {
|
||||
console.log("Not playing right now")
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",artist:artist,title:title})
|
||||
chrome.runtime.sendMessage({type:"stopPlayback",time:Math.floor(Date.now()),artist:artist,title:title})
|
||||
//stopPlayback()
|
||||
}
|
||||
else if (control == "Pause") {
|
||||
console.log("Playing " + artist + " - " + title)
|
||||
chrome.runtime.sendMessage({type:"startPlayback",artist:artist,title:title,duration:durationSeconds})
|
||||
chrome.runtime.sendMessage({type:"startPlayback",time:Math.floor(Date.now()),artist:artist,title:title,duration:durationSeconds})
|
||||
//startPlayback(artist,title,durationSeconds)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user