Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/commands/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ export async function play(
await printBanner();
const normalizedQuality = quality?.toLowerCase();

if (volume) {
const volumeNumber = Number(volume);

if (volumeNumber < 0 || volumeNumber > 1) {
return error('Volume should be between 0 and 1');
}
const volumeNumber = Number(volume);

if (
volume.trim() === '' ||
!Number.isFinite(volumeNumber) ||
volumeNumber < 0 ||
volumeNumber > 1
) {
return error('Volume should be a number between 0 and 1');
}

if (normalizedQuality && !supportedQualities.includes(normalizedQuality)) {
Expand Down Expand Up @@ -89,7 +92,7 @@ export async function play(
}
console.log(`${chalk.cyan(divider)}`);

await playAudio(station.title, Number(volume), streamUrl);
await playAudio(station.title, volumeNumber, streamUrl);
} catch (err) {
if (err instanceof Error) {
error(`Error: ${err.message}`);
Expand Down