summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/menus/main.lua6
-rw-r--r--not/MusicPlayer.lua8
2 files changed, 12 insertions, 2 deletions
diff --git a/config/menus/main.lua b/config/menus/main.lua
index 95e44ec..ae2cef2 100644
--- a/config/menus/main.lua
+++ b/config/menus/main.lua
@@ -14,8 +14,10 @@ if background == nil or not background:is(require "not.MenuBackground") then
end
-- Wait, only here?
-musicPlayer:setTrack("menu.ogg")
-musicPlayer:play()
+if musicPlayer:getCurrentTrack() ~= "menu.ogg" then
+ musicPlayer:setTrack("menu.ogg")
+ musicPlayer:play()
+end
return {
background,
diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua
index e838d96..4634ed9 100644
--- a/not/MusicPlayer.lua
+++ b/not/MusicPlayer.lua
@@ -32,6 +32,14 @@ function MusicPlayer:setTrack (trackName)
end
end
+function MusicPlayer:getCurrentTrack ()
+ for key,track in pairs(self.tracks) do
+ if self.tracks[key] == self.source then
+ return key
+ end
+ end
+end
+
function MusicPlayer:play ()
self.source:play()
end