Skip to content

Commit d994000

Browse files
committed
Add music file playlist removal
Going to the menu now unmounts all mounted music directories. Meaning, the music in the playlist will be forgotten when the menu button is pressed. Thus, you can now remove songs from the playlist.
1 parent 1e23f7a commit d994000

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

audio.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ local is_paused = false
5858
local loop_toggle = config.loop
5959
local shuffle_toggle = config.shuffle
6060
local shuffle_history = {}
61+
local mount_history = {}
6162

6263
if not love.filesystem.getInfo("music") then
6364
love.filesystem.createDirectory("music")
@@ -77,6 +78,11 @@ function audio.reload()
7778
audio.stop()
7879
end
7980

81+
-- Unmount all music directories.
82+
for i,v in ipairs(mount_history) do
83+
love.filesystem.unmount(v)
84+
end
85+
8086
sample_sum = 0
8187
sample_counts = {0, 0, 0, 0, 0, 0, 0, 0}
8288
sounddata_array = {}
@@ -98,18 +104,23 @@ function audio.reload()
98104
rd_active = false
99105
is_paused = false
100106
shuffle_history = {}
107+
mount_history = {}
101108

102109
end
103110

104111
--- Attempts to load music in the folder "mount".
112+
-- @param path string: Path of music folder to mount and load.
105113
-- @return boolean: True if successful. False otherwise.
106-
function audio.music.load()
114+
function audio.music.load(path)
107115

108116
if rd_active then
109117
return
110118
end
119+
120+
mount_history[#mount_history+1] = path
111121

112122
shuffle_history = {}
123+
love.filesystem.mount(path, "mount")
113124
music_list = audio.music.recursiveEnumerate("mount")
114125

115126
if not next(music_list) then

main.lua

+3-6
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ function love.load()
317317
end
318318
end
319319
elseif config.init_location == "appdata" then
320-
love.filesystem.mount("music", "mount")
321-
appdata_music_success = audio.music.load()
320+
appdata_music_success = audio.music.load("music")
322321
elseif config.init_location == "dragndrop" then
323322
dragndrop = true
324323
end
@@ -540,8 +539,7 @@ function love.keypressed(key, scancode, isrepeat)
540539

541540
-- Select music from appdata.
542541
elseif key_int == 2 then
543-
love.filesystem.mount("music", "mount")
544-
appdata_music_success = audio.music.load()
542+
appdata_music_success = audio.music.load("music")
545543
end
546544
end
547545

@@ -568,8 +566,7 @@ end
568566
-- @param path string: Path of directory dropped.
569567
function love.directorydropped(path)
570568

571-
love.filesystem.mount(path, "mount")
572-
audio.music.load()
569+
audio.music.load(path)
573570

574571
end
575572

0 commit comments

Comments
 (0)