OnAir including currently playing from st1

This commit is contained in:
2021-01-04 20:34:57 +01:00
parent 25ec7db2ce
commit 444ad56464

View File

@@ -245,9 +245,9 @@ QUERY;
}
private function getTrack($next = false) {
private function getTrack($studio = 'nonstop', $next = false) {
$prefix = $next ? "next" : "current";
$data = app('db')->select("SELECT {$prefix}_start AS start, {$prefix}_itemcode AS itemCode, {$prefix}_title AS title, {$prefix}_artist AS artist, {$prefix}_duration AS duration FROM `now_playing`");
$data = app('db')->select("SELECT {$prefix}_start AS start, {$prefix}_itemcode AS itemCode, {$prefix}_title AS title, {$prefix}_artist AS artist, {$prefix}_duration AS duration FROM `now_playing` WHERE `studio` = :studio", ['studio' => $studio]);
return new \Model\Track($data[0]);
}
@@ -279,21 +279,31 @@ QUERY;
$schema = $this->createSchedule($start, $einde);
$program = $schema['schedule'][0]['program'];
if($program->nonstop) {
$current = $this->getTrack();
$next = $this->getTrack(/* next: */ true);
$current->ends($next->start);
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
if(!$next->isLayout()) {
$current = $next;
}
}
return response()->json(['inProgram' => false, 'stream' => $this->isStreamEnabled(), 'current' => $current, 'program' => $program]);
} else {
$canStream = $this->isStreamEnabled();
return response()->json(['inProgram' => true, 'stream' => $canStream, 'program' => $program]);
$activeStudioQuery = app('db')->select("SELECT `studio` FROM `programs_schedule_webcam` WHERE `active` = 1");
if(!count($activeStudioQuery) || !($activeStudio = $activeStudioQuery[0]->studio)) {
$activeStudio = 'nonstop';
}
$current = $this->getTrack($activeStudio);
$next = $this->getTrack($activeStudio, /* next: */ true);
$current->ends($next->start);
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
if(!$next->isLayout()) {
$current = $next;
}
}
$data = [
'inProgram' => !$program->nonstop,
'program' => $program,
'stream' => $this->isStreamEnabled(),
];
if($current && !$current->isLayout() && $current->title) {
$data['current'] = $current;
}
return response()->json($data);
}
public function onair_text(Request $request) {
@@ -302,9 +312,19 @@ QUERY;
$schema = $this->createSchedule($start, $einde);
$program = $schema['schedule'][0]['program'];
if(!$program->nonstop) {
$current = $this->getTrack();
$next = $this->getTrack(/* next: */ true);
$activeStudioQuery = app('db')->select("SELECT `studio` FROM `programs_schedule_webcam` WHERE `active` = 1");
if(!count($activeStudioQuery) || !($activeStudio = $activeStudioQuery[0]->studio)) {
$activeStudio = 'nonstop';
}
$text = [];
if(!$program->nonstop) {
$text[] = $program->name;
}
if($activeStudio) {
$current = $this->getTrack($activeStudio);
$next = $this->getTrack($activeStudio, /* next: */ true);
$current->ends($next->start);
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
if(!$next->isLayout()) {
@@ -312,12 +332,13 @@ QUERY;
}
}
return $request->get('program_only', false)
? $program->name
: $program->name . " - " . $current->title . " - " . $current->artist;
} else {
return $program->name;
if(!$request->get('program_only', false) && !($current->isLayout())) {
if($current->title) $text[] = $current->title;
if($current->artist) $text[] = $currenet->artist;
}
}
return join(' - ', $text);
}
/**