Skip to content

Commit 3405f23

Browse files
committed
fix: intro music pausing
1 parent 31ed7e6 commit 3405f23

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

musicloader.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ end
133133

134134
function music:getPlaying()
135135
for name, source in pairs(self.loaded) do
136-
if source:isPlaying() then
136+
if isActive(source) then
137137
return name, source
138138
end
139139
end
@@ -147,7 +147,7 @@ function music:update()
147147
end
148148
end
149149
if intromusic then
150-
if self.loaded[intromusic[1]] and not self.loaded[intromusic[1]]:isPlaying() then
150+
if self.loaded[intromusic[1]] and not isActive(self.loaded[intromusic[1]]) then
151151
music:play(intromusic[2], nil, true)
152152
intromusic = false
153153
end
@@ -156,7 +156,7 @@ end
156156

157157
function music:playingmusic()
158158
for name, source in pairs(self.loaded) do
159-
if source ~= false and source:isPlaying() then
159+
if source and isActive(source) then
160160
return true
161161
end
162162
end

utils.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,16 @@ function hasvalue(tab, val)
6565
end
6666
end
6767
return false
68-
end
68+
end
69+
70+
function isPaused(source)
71+
return pausedaudio and hasvalue(pausedaudio, source)
72+
end
73+
74+
function isStopped(source)
75+
return not source:isPlaying() and not isPaused(source)
76+
end
77+
78+
function isActive(source)
79+
return source:isPlaying() or isPaused(source)
80+
end

0 commit comments

Comments
 (0)