Add HLS to playlist; auto-redirect players visiting public pages.

This commit is contained in:
Buster Neece 2022-11-18 01:55:53 -06:00
parent 3068f7c4e7
commit 8c7a4d7854
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
3 changed files with 40 additions and 3 deletions

View File

@ -20,8 +20,13 @@ release channel, you can take advantage of these new features and fixes.
- Because both our Docker and Ansible installations are managed by Supervisor now, we can view the realtime status of
all essential application services, and even restart them directly from the web interface.
- If you enter the link for a public player page into a media player app (i.e. VLC), it will automatically redirect to
the playlist file and play appropriately.
## Bug Fixes
- HLS streams will now be included in Playlist (PLS/M3U) file downloads.
- Fixed an issue where listener connection times over a day didn't properly show up.
- Fixed several issues contributing to slow load times on media manager pages.

View File

@ -76,13 +76,24 @@ final class PlayerAction
);
}
// Render full page player.
$props['stationName'] = $station->getName();
$props['enableRequests'] = $station->getEnableRequests();
$props['downloadPlaylistUri'] = $router->named(
'public:playlist',
['station_id' => $station->getShortName(), 'format' => 'pls']
);
// Auto-redirect requests from players to the playlist (PLS) download.
$userAgent = strtolower($request->getHeaderLine('User-Agent'));
$players = ['mpv', 'player', 'vlc', 'applecoremedia'];
foreach ($players as $player) {
if (str_contains($userAgent, $player)) {
return $response->withRedirect($props['downloadPlaylistUri']);
}
}
// Render full page player.
$props['stationName'] = $station->getName();
$props['enableRequests'] = $station->getEnableRequests();
$props['requestListUri'] = $router->named(
'api:requests:list',
['station_id' => $station->getId()]

View File

@ -61,6 +61,27 @@ final class PlaylistAction
];
}
if ($station->getEnableHls() && $station->getBackendTypeEnum()->isEnabled()) {
$backend = $this->adapters->getBackendAdapter($station);
$backendConfig = $station->getBackendConfig();
if (null !== $backend && $backendConfig->getHlsEnableOnPublicPlayer()) {
$streamUrl = $backend->getHlsUrl($station);
$streamRow = [
'name' => $station->getName() . ' - HLS',
'url' => (string)$streamUrl,
];
if ($backendConfig->getHlsIsDefault()) {
array_unshift($stream_urls, $streamUrl);
array_unshift($streams, $streamRow);
} else {
$stream_urls[] = $streamUrl;
$streams[] = $streamRow;
}
}
}
$format = strtolower($format);
switch ($format) {
// M3U Playlist Format