feat(media): default music volume 30% instead of 100%

Volume play music terlalu besar buat user — default sekarang 0.3 (30%)
di semua layer: player gateway (musicVolume=0.3), backend state/schema
(default 0.3), dan UI slider (fallback 0.3). User tetap bisa naikin
manual via slider volume di dashboard.
This commit is contained in:
asepharyana
2026-08-07 13:41:12 +07:00
parent 4797aca20f
commit 62ffb676f9
5 changed files with 7 additions and 7 deletions
@@ -6,7 +6,7 @@ export const mediaQueueSchema = z.object({
}); });
export const mediaVolumeSchema = z.object({ export const mediaVolumeSchema = z.object({
volume: z.number().min(0).max(1).default(1.0), volume: z.number().min(0).max(1).default(0.3),
}); });
export type MediaQueueInput = z.infer<typeof mediaQueueSchema>; export type MediaQueueInput = z.infer<typeof mediaQueueSchema>;
@@ -44,7 +44,7 @@ const DEFAULT_COMMAND_TIMEOUT_MS = 5000;
const DEFAULT_STATE: MediaState = { const DEFAULT_STATE: MediaState = {
playing: false, playing: false,
activeMode: null, activeMode: null,
musicVolume: 1.0, musicVolume: 0.3,
current: null, current: null,
queue: [], queue: [],
}; };
@@ -65,7 +65,7 @@ function normalizeMediaState(raw: Record<string, unknown>): MediaState {
return { return {
playing, playing,
activeMode, activeMode,
musicVolume: Number(raw.musicVolume ?? 1.0), musicVolume: Number(raw.musicVolume ?? 0.3),
current: (raw.current as MediaItem | null) ?? null, current: (raw.current as MediaItem | null) ?? null,
queue: (raw.queue as MediaItem[]) ?? [], queue: (raw.queue as MediaItem[]) ?? [],
}; };
@@ -18,7 +18,7 @@ export class DiscordPlayer {
private connection: VoiceConnection | null = null; private connection: VoiceConnection | null = null;
private owner: DiscordPlayerOwner = "none"; private owner: DiscordPlayerOwner = "none";
private resource: AudioResource | null = null; private resource: AudioResource | null = null;
private musicVolume = 1; private musicVolume = 0.3;
private idleCallback: (() => void) | null = null; private idleCallback: (() => void) | null = null;
/** Set before manual stop() calls to distinguish from natural track end. */ /** Set before manual stop() calls to distinguish from natural track end. */
private manualStop = false; private manualStop = false;
@@ -147,8 +147,8 @@ export function MusicPlayer({ ws, initialData }: MusicPlayerProps) {
<Volume2 className="size-4 text-muted-foreground" /> <Volume2 className="size-4 text-muted-foreground" />
<Slider <Slider
className="w-24" className="w-24"
defaultValue={[mediaState?.musicVolume ?? 0.5]} defaultValue={[mediaState?.musicVolume ?? 0.3]}
value={[mediaState?.musicVolume ?? 0.5]} value={[mediaState?.musicVolume ?? 0.3]}
onValueChange={handleVolume} onValueChange={handleVolume}
min={0} min={0}
max={1} max={1}
@@ -41,7 +41,7 @@ export function MediaPlayerProvider({ children }: { children: ReactNode }) {
const ws = useWebSocket(); const ws = useWebSocket();
const [state, setState] = useState<MediaState>({ const [state, setState] = useState<MediaState>({
playing: false, playing: false,
musicVolume: 0.5, musicVolume: 0.3,
current: null, current: null,
queue: [], queue: [],
}); });