4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 21:26:37 +00:00

Fixes #6712 -- Add "hls_is_default" to NP station API endpoint and use it on player frontend.

This commit is contained in:
Buster Neece 2023-12-19 19:55:20 -06:00
parent f85d91aade
commit c8bcee0ad8
No known key found for this signature in database
4 changed files with 15 additions and 7 deletions

View File

@ -178,16 +178,20 @@ const currentStream = shallowRef<CurrentStreamDescriptor>({
hls: false,
});
const enable_hls = computed(() => {
const enableHls = computed(() => {
return props.showHls && np.value?.station?.hls_enabled;
});
const hlsIsDefault = computed(() => {
return enableHls.value && np.value?.station?.hls_is_default;
});
const {$gettext} = useTranslate();
const streams = computed<CurrentStreamDescriptor[]>(() => {
const allStreams = [];
if (enable_hls.value) {
if (enableHls.value) {
allStreams.push({
name: $gettext('HLS'),
url: np.value?.station?.hls_url,
@ -260,7 +264,7 @@ const onNowPlayingUpdated = (np_new) => {
let $currentStream = currentStream.value;
if ($currentStream.url === '' && $streams.length > 0) {
if (props.hlsIsDefault && enable_hls.value) {
if (hlsIsDefault.value) {
currentStream.value = $streams[0];
} else {
$currentStream = null;

View File

@ -6,10 +6,6 @@ export default {
type: Boolean,
default: true
},
hlsIsDefault: {
type: Boolean,
default: true
},
showAlbumArt: {
type: Boolean,
default: true

View File

@ -101,6 +101,12 @@ final class Station implements ResolvableUrlInterface
)]
public bool $hls_enabled = false;
#[OA\Property(
description: 'If the HLS stream should be the default one for the station.',
example: true
)]
public bool $hls_is_default = false;
#[OA\Property(
description: 'The full URL to listen to the HLS stream for the station.',
example: 'https://example.com/hls/azuratest_radio/live.m3u8',

View File

@ -76,6 +76,8 @@ final class StationApiGenerator
$response->remotes = $remotes;
$response->hls_enabled = $station->getBackendType()->isEnabled() && $station->getEnableHls();
$response->hls_is_default = $response->hls_enabled && $station->getBackendConfig()->getHlsIsDefault();
$response->hls_url = (null !== $backend && $response->hls_enabled)
? $backend->getHlsUrl($station, $baseUri)
: null;