Handle "Jingle Mode" in LS code.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-02-16 02:21:25 -06:00
parent 76e48106a0
commit a74de7bd43
No known key found for this signature in database
GPG Key ID: 9FC8B9E008872109
3 changed files with 15 additions and 27 deletions

View File

@ -124,16 +124,6 @@ class StationQueueRepository extends Repository
return $this->getUnplayedBaseQuery($station)->getQuery();
}
public function getLatestVisibleRow(Entity\Station $station): ?Entity\StationQueue
{
return $this->getRecentBaseQuery($station)
->andWhere('sq.sent_to_autodj = 1')
->andWhere('sq.is_visible = 1')
->getQuery()
->setMaxResults(1)
->getOneOrNullResult();
}
public function clearUpcomingQueue(Entity\Station $station): void
{
$this->em->createQuery(

View File

@ -108,27 +108,10 @@ class Annotations implements EventSubscriberInterface
return;
}
// Handle "Jingle mode" by sending the same metadata as the previous song.
if ($playlist->getIsJingle()) {
$event->addAnnotations([
'jingle_mode' => 'true',
]);
$queue = $event->getQueue();
if (null !== $queue) {
$lastVisible = $this->queueRepo->getLatestVisibleRow($event->getStation());
if (null !== $lastVisible) {
$event->addAnnotations(
[
'title' => $lastVisible->getTitle(),
'artist' => $lastVisible->getArtist(),
'playlist_id' => null,
'media_id' => null,
]
);
}
}
} else {
$event->addAnnotations([
'playlist_id' => $playlist->getId(),

View File

@ -962,6 +962,21 @@ class ConfigWriter implements EventSubscriberInterface
$event->appendBlock(
<<<EOF
# Handle "Jingle Mode" tracks by replaying the previous metadata.
last_title = ref("")
last_artist = ref("")
def handle_jingle_mode(m) =
if (m["jingle_mode"] == "true") then
[("title", !last_title), ("artist", !last_artist)]
else
last_title := m["title"]
last_artist := m["artist"]
m
end
end
radio = map_metadata(handle_jingle_mode, radio)
# Send metadata changes back to AzuraCast
def metadata_updated(m) =
def f() =