Restore missing annotateNextSong fixes from cpeter1207 (#4373)

This commit is contained in:
Vaalyn 2021-07-08 21:02:19 +02:00 committed by GitHub
parent 8b113ace37
commit 18eb64c61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -94,14 +94,26 @@ class AutoDJ
return $this->annotateNextSong($station, $asAutoDj, $iteration + 1);
}
// Build adjusted "now" based on the currently playing song before annotating up the next one
$adjustedNow = $this->getAdjustedNow(
$station,
$this->getNowFromCurrentSong($station),
$queueRow->getDuration()
);
$event = new AnnotateNextSong($queueRow, $asAutoDj);
$this->dispatcher->dispatch($event);
// Refill station queue while taking into context that LS queues songs 40s before they are played
$this->buildQueue($station, true, $adjustedNow);
return $event->buildAnnotations();
}
public function buildQueue(
Entity\Station $station,
bool $force = false
bool $force = false,
CarbonInterface $nowOverride = null
): void {
$lock = $this->lockFactory->createAndAcquireLock(
resource: 'autodj_queue_' . $station->getId(),
@ -125,7 +137,7 @@ class AutoDJ
);
// Adjust "now" time from current queue.
$now = $this->getNowFromCurrentSong($station);
$now = $nowOverride ?? $this->getNowFromCurrentSong($station);
$maxQueueLength = $station->getBackendConfig()->getAutoDjQueueLength();
if ($maxQueueLength < 1) {