fix: make !volume apply immediately during playback
stream_audio now accepts a callable for volume, re-read on each PCM frame instead of capturing a static float at track start. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -78,10 +78,11 @@ async def _play_loop(bot) -> None:
|
||||
done = asyncio.Event()
|
||||
ps["done_event"] = done
|
||||
|
||||
volume = ps["volume"] / 100.0
|
||||
try:
|
||||
await bot.stream_audio(
|
||||
track.url, volume=volume, on_done=done,
|
||||
track.url,
|
||||
volume=lambda: ps["volume"] / 100.0,
|
||||
on_done=done,
|
||||
)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
@@ -269,7 +270,7 @@ async def cmd_volume(bot, message):
|
||||
|
||||
Usage:
|
||||
!volume Show current volume
|
||||
!volume <0-100> Set volume (applies on next track)
|
||||
!volume <0-100> Set volume (takes effect immediately)
|
||||
"""
|
||||
if not _is_mumble(bot):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user