2018-02-01 12:49:40 +01:00
|
|
|
<?php
|
2020-10-15 00:19:31 +02:00
|
|
|
|
2021-07-19 07:53:45 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-08-05 00:05:14 +02:00
|
|
|
namespace App\Controller\Stations;
|
2018-02-01 12:49:40 +01:00
|
|
|
|
2018-08-05 00:05:14 +02:00
|
|
|
use App\Entity;
|
2019-09-10 18:40:31 +02:00
|
|
|
use App\Exception\StationUnsupportedException;
|
2019-08-09 17:00:21 +02:00
|
|
|
use App\Http\Response;
|
|
|
|
use App\Http\ServerRequest;
|
2022-06-22 03:48:32 +02:00
|
|
|
use App\Radio\Adapters;
|
2019-08-10 09:45:17 +02:00
|
|
|
use App\Service\AzuraCastCentral;
|
2018-11-17 16:30:28 +01:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
2018-02-01 12:49:40 +01:00
|
|
|
|
2022-05-22 02:27:28 +02:00
|
|
|
final class StreamersAction
|
2018-02-01 12:49:40 +01:00
|
|
|
{
|
2022-05-22 02:27:28 +02:00
|
|
|
public function __construct(
|
|
|
|
private readonly AzuraCastCentral $acCentral,
|
2022-06-22 03:48:32 +02:00
|
|
|
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
|
|
|
private readonly Adapters $adapters,
|
2022-05-22 02:27:28 +02:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2021-02-09 20:57:25 +01:00
|
|
|
public function __invoke(
|
|
|
|
ServerRequest $request,
|
|
|
|
Response $response,
|
2022-05-24 07:50:43 +02:00
|
|
|
string $station_id
|
2021-02-09 20:57:25 +01:00
|
|
|
): ResponseInterface {
|
2019-08-09 17:00:21 +02:00
|
|
|
$station = $request->getStation();
|
2022-06-22 03:48:32 +02:00
|
|
|
$backend = $this->adapters->getBackendAdapter($station);
|
2018-02-01 12:49:40 +01:00
|
|
|
|
2022-06-22 03:48:32 +02:00
|
|
|
if (null === $backend || !$station->getEnableStreamers()) {
|
2020-10-15 00:19:31 +02:00
|
|
|
throw new StationUnsupportedException();
|
2018-02-01 12:49:40 +01:00
|
|
|
}
|
|
|
|
|
2022-05-22 02:27:28 +02:00
|
|
|
$settings = $this->settingsRepo->readSettings();
|
2021-10-08 06:13:21 +02:00
|
|
|
$backendConfig = $station->getBackendConfig();
|
2019-12-07 13:19:49 +01:00
|
|
|
|
2021-10-08 06:13:21 +02:00
|
|
|
$router = $request->getRouter();
|
|
|
|
|
2021-10-08 10:49:41 +02:00
|
|
|
return $request->getView()->renderVuePage(
|
|
|
|
response: $response,
|
|
|
|
component: 'Vue_StationsStreamers',
|
|
|
|
id: 'station-streamers',
|
|
|
|
title: __('Streamer/DJ Accounts'),
|
|
|
|
props: [
|
|
|
|
'listUrl' => (string)$router->fromHere('api:stations:streamers'),
|
2022-05-31 06:23:03 +02:00
|
|
|
'newArtUrl' => (string)$router->fromHere('api:stations:streamers:new-art'),
|
2021-10-08 10:49:41 +02:00
|
|
|
'scheduleUrl' => (string)$router->fromHere('api:stations:streamers:schedule'),
|
|
|
|
'stationTimeZone' => $station->getTimezone(),
|
|
|
|
'connectionInfo' => [
|
|
|
|
'serverUrl' => $settings->getBaseUrl(),
|
|
|
|
'streamPort' => $backend->getStreamPort($station),
|
2022-05-22 02:27:28 +02:00
|
|
|
'ip' => $this->acCentral->getIp(),
|
2021-10-08 10:49:41 +02:00
|
|
|
'djMountPoint' => $backendConfig->getDjMountPoint(),
|
2021-10-08 06:13:21 +02:00
|
|
|
],
|
2020-12-10 23:46:03 +01:00
|
|
|
]
|
|
|
|
);
|
2018-02-01 12:49:40 +01:00
|
|
|
}
|
2018-08-05 00:05:14 +02:00
|
|
|
}
|