Handle "Jingle Mode" in LS code.
This commit is contained in:
parent
76e48106a0
commit
a74de7bd43
|
@ -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(
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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() =
|
||||
|
|
Loading…
Reference in New Issue