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";
|
$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]);
|
return new \Model\Track($data[0]);
|
||||||
}
|
}
|
||||||
@@ -279,9 +279,13 @@ QUERY;
|
|||||||
$schema = $this->createSchedule($start, $einde);
|
$schema = $this->createSchedule($start, $einde);
|
||||||
$program = $schema['schedule'][0]['program'];
|
$program = $schema['schedule'][0]['program'];
|
||||||
|
|
||||||
if($program->nonstop) {
|
$activeStudioQuery = app('db')->select("SELECT `studio` FROM `programs_schedule_webcam` WHERE `active` = 1");
|
||||||
$current = $this->getTrack();
|
if(!count($activeStudioQuery) || !($activeStudio = $activeStudioQuery[0]->studio)) {
|
||||||
$next = $this->getTrack(/* next: */ true);
|
$activeStudio = 'nonstop';
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = $this->getTrack($activeStudio);
|
||||||
|
$next = $this->getTrack($activeStudio, /* next: */ true);
|
||||||
$current->ends($next->start);
|
$current->ends($next->start);
|
||||||
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
|
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
|
||||||
if(!$next->isLayout()) {
|
if(!$next->isLayout()) {
|
||||||
@@ -289,11 +293,17 @@ QUERY;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(['inProgram' => false, 'stream' => $this->isStreamEnabled(), 'current' => $current, 'program' => $program]);
|
$data = [
|
||||||
} else {
|
'inProgram' => !$program->nonstop,
|
||||||
$canStream = $this->isStreamEnabled();
|
'program' => $program,
|
||||||
return response()->json(['inProgram' => true, 'stream' => $canStream, 'program' => $program]);
|
'stream' => $this->isStreamEnabled(),
|
||||||
|
];
|
||||||
|
|
||||||
|
if($current && !$current->isLayout() && $current->title) {
|
||||||
|
$data['current'] = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onair_text(Request $request) {
|
public function onair_text(Request $request) {
|
||||||
@@ -302,9 +312,19 @@ QUERY;
|
|||||||
$schema = $this->createSchedule($start, $einde);
|
$schema = $this->createSchedule($start, $einde);
|
||||||
$program = $schema['schedule'][0]['program'];
|
$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) {
|
if(!$program->nonstop) {
|
||||||
$current = $this->getTrack();
|
$text[] = $program->name;
|
||||||
$next = $this->getTrack(/* next: */ true);
|
}
|
||||||
|
|
||||||
|
if($activeStudio) {
|
||||||
|
$current = $this->getTrack($activeStudio);
|
||||||
|
$next = $this->getTrack($activeStudio, /* next: */ true);
|
||||||
$current->ends($next->start);
|
$current->ends($next->start);
|
||||||
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
|
if($current->isLayout() /* || $current->secondsRemaining() < 0 */) {
|
||||||
if(!$next->isLayout()) {
|
if(!$next->isLayout()) {
|
||||||
@@ -312,14 +332,15 @@ QUERY;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request->get('program_only', false)
|
if(!$request->get('program_only', false) && !($current->isLayout())) {
|
||||||
? $program->name
|
if($current->title) $text[] = $current->title;
|
||||||
: $program->name . " - " . $current->title . " - " . $current->artist;
|
if($current->artist) $text[] = $currenet->artist;
|
||||||
} else {
|
|
||||||
return $program->name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return join(' - ', $text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Programmas nu en straks (24 uur vooruit)
|
* Programmas nu en straks (24 uur vooruit)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user