Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fixes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 30, 2023
1 parent dad2642 commit 6e2a2a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ for _, playlistFolder in playlists:GetChildren() do
volumeKnobs.off[playlistFolder.Name] = createKnob(nextAudioInstance, false)

switches.play[playlistFolder.Name] = function()
nextAudioInstance:Play()
if nextAudioInstance.IsPaused then
nextAudioInstance:Resume()
else
nextAudioInstance:Play()
end
end
switches.pause[playlistFolder.Name] = function()
nextAudioInstance:Pause()
Expand All @@ -73,6 +77,7 @@ for _, playlistFolder in playlists:GetChildren() do
nextAudioInstance.Name = playlistFolder.Name
nextAudioInstance.Parent = soundFolder
nextAudioInstance.Ended:Wait()
print "ended"
end
end
end)
Expand Down
26 changes: 20 additions & 6 deletions src/client/GameAtmosphere/Soundscape/SoundSystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,36 @@ local volumeKnobs, switches =
local player = Players.LocalPlayer

store.changed:connect(function(newState, oldState)
local oldPrimarySoundRegion = selectors.getAudioData(oldState, player.Name).PrimarySoundRegion
local newPrimarySoundRegion = selectors.getAudioData(newState, player.Name).PrimarySoundRegion
local newBackgroundMusicSetting = selectors.getSetting(newState, player.Name, "BackgroundMusic")
local oldBackgroundMusicSetting = selectors.getSetting(oldState, player.Name, "BackgroundMusic")

if not selectors.getSetting(newState, player.Name, "BackgroundMusic") then
newPrimarySoundRegion = nil
if not newBackgroundMusicSetting then
volumeKnobs.on[newPrimarySoundRegion]:Cancel()
volumeKnobs.off[newPrimarySoundRegion]:Play()
return
end

if oldBackgroundMusicSetting ~= newBackgroundMusicSetting then
volumeKnobs.off[newPrimarySoundRegion]:Cancel()
switches.play[newPrimarySoundRegion]()
volumeKnobs.on[newPrimarySoundRegion]:Play()
return
end
end)

store.changed:connect(function(newState, oldState)
local oldPrimarySoundRegion = selectors.getAudioData(oldState, player.Name).PrimarySoundRegion
local newPrimarySoundRegion = selectors.getAudioData(newState, player.Name).PrimarySoundRegion

if oldPrimarySoundRegion ~= newPrimarySoundRegion or not oldBackgroundMusicSetting then
if oldPrimarySoundRegion ~= newPrimarySoundRegion then
if newPrimarySoundRegion then
if oldPrimarySoundRegion then
if oldPrimarySoundRegion and oldPrimarySoundRegion ~= newPrimarySoundRegion then
volumeKnobs.off[oldPrimarySoundRegion]:Play()
end
switches.play[newPrimarySoundRegion]()
volumeKnobs.on[newPrimarySoundRegion]:Play()
else
elseif oldPrimarySoundRegion then
volumeKnobs.on[oldPrimarySoundRegion]:Cancel()
volumeKnobs.off[oldPrimarySoundRegion]:Play()
end
Expand Down

0 comments on commit 6e2a2a4

Please sign in to comment.