19 lines
608 B
Lua
19 lines
608 B
Lua
music_manager={}
|
|
add(modules,music_manager)
|
|
function music_manager:init()
|
|
self._allow=true
|
|
end
|
|
function music_manager:allow(a)
|
|
self._allow=a
|
|
end
|
|
function music_manager:update()
|
|
if (not self._allow) music(-1,0) return
|
|
local is_playing = stat(54) != -1
|
|
local should_be_playing = completion_tracker:get_music_preference()
|
|
if (is_playing and not should_be_playing) music(-1,500)
|
|
if (not is_playing and should_be_playing) music(0)
|
|
|
|
local label,pref="start music",true
|
|
if (should_be_playing) label,pref="stop music",false
|
|
menuitem(1,label,function() completion_tracker:set_music_preference(pref) end)
|
|
end |