OnAir including currently playing from st1
This commit is contained in:
@@ -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,9 +279,13 @@ 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';
|
||||
}
|
||||
|
||||
$current = $this->getTrack($activeStudio);
|
||||
$next = $this->getTrack($activeStudio, /* next: */ true);
|
||||
$current->ends($next->start);
|
||||
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
|
||||
if(!$next->isLayout()) {
|
||||
@@ -289,11 +293,17 @@ QUERY;
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
$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'];
|
||||
|
||||
$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) {
|
||||
$current = $this->getTrack();
|
||||
$next = $this->getTrack(/* next: */ true);
|
||||
$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,14 +332,15 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmas nu en straks (24 uur vooruit)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user