Live now playing info
This commit is contained in:
@@ -246,6 +246,14 @@ if($DEBUG) print "Creating schedule between {$start->format('Y-m-d H:i')} and {$
|
||||
return response()->json($program);
|
||||
}
|
||||
|
||||
|
||||
private function getTrack($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`");
|
||||
|
||||
return new \Model\Track($data[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmas nu en straks (24 uur vooruit)
|
||||
*/
|
||||
@@ -253,7 +261,23 @@ if($DEBUG) print "Creating schedule between {$start->format('Y-m-d H:i')} and {$
|
||||
$start = new \DateTimeImmutable('now');
|
||||
$einde = new \DateTimeImmutable('now + 1 second');
|
||||
$schema = $this->createSchedule($start, $einde);
|
||||
return response()->json(['current' => ['program' => true, 'name' => $schema['schedule'][0]['program']->name]]);
|
||||
$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()) {
|
||||
return response()->json(['inProgram' => true, 'current' => $program->name]);
|
||||
}
|
||||
|
||||
$current = $next;
|
||||
}
|
||||
|
||||
return response()->json(['inProgram' => false, 'current' => $current]);
|
||||
} else {
|
||||
return response()->json(['inProgram' => true, 'current' => $program->name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user