-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.lua
49 lines (43 loc) · 1.05 KB
/
player.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--[[
This file contains all logic related to music player (of-course trivial!)
]]
local function getRandomSongNumber()
local r=love.math.random(1,#music)
if r==current then
getRandomSongNumber()
else
current=r
end
end
function randomSong()
if not music[current] then return end
music[current].sound:stop()
getRandomSongNumber()
updateSong()
end
function nextSong()
if not music[current] then return end
music[current].sound:stop()
current=current+1
if current>#music then current=1 end
updateSong()
end
function previousSong()
if not music[current] then return end
music[current].sound:stop()
current=current-1
if current<1 then current=#music end
updateSong()
end
function updateSong()
if not music[current] then return end
discLabel.text=music[current].songName
artistLabel.text=music[current].artistName
albumLabel.text=music[current].albumName
discImage=music[current].image or gi.image
soundSlider.max=music[current].sound:getDuration()
soundSlider.value=0
if playBtn.image~=gi.playBtn then
music[current].sound:play()
end
end