From 5fbd4f54a22df1c66c56d54360908ce62439ce5f Mon Sep 17 00:00:00 2001
From: jo <ljonas@riseup.net>
Date: Sun, 26 Feb 2023 16:28:26 +0100
Subject: [PATCH] fix(legacy): on air light fails when no shows are scheduled

---
 legacy/application/controllers/ApiController.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/legacy/application/controllers/ApiController.php b/legacy/application/controllers/ApiController.php
index 27d7ff12d..c5f8d55e2 100644
--- a/legacy/application/controllers/ApiController.php
+++ b/legacy/application/controllers/ApiController.php
@@ -207,9 +207,12 @@ class ApiController extends Zend_Controller_Action
 
         $range = Application_Model_Schedule::GetPlayOrderRange();
 
-        $isItemCurrentlyScheduled = !is_null($range['tracks']['current']) && count($range['tracks']['current']) > 0 ? true : false;
-
-        $isCurrentItemPlaying = $range['tracks']['current']['media_item_played'] ? true : false;
+        $isItemCurrentlyScheduled = false;
+        $isCurrentItemPlaying = false;
+        if (!is_null($range['tracks']['current']) && count($range['tracks']['current']) > 0) {
+            $isItemCurrentlyScheduled = true;
+            $isCurrentItemPlaying = $range['tracks']['current']['media_item_played'] ? true : false;
+        }
 
         if (
             $isItemCurrentlyScheduled