整理代码
This commit is contained in:
@@ -12,26 +12,6 @@ local BGM={
|
|||||||
--lastPlayed=[str:lastPlayed ID]
|
--lastPlayed=[str:lastPlayed ID]
|
||||||
}
|
}
|
||||||
|
|
||||||
function BGM.getList()return nameList end
|
|
||||||
function BGM.getCount()return #nameList end
|
|
||||||
local function _addFile(name,path)
|
|
||||||
if not SourceObjList[name]then
|
|
||||||
table.insert(nameList,name)
|
|
||||||
SourceObjList[name]={path=path,source=false}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function BGM.load(name,path)
|
|
||||||
if type(name)=='table'then
|
|
||||||
for k,v in next,name do
|
|
||||||
_addFile(k,v)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
_addFile(name,path)
|
|
||||||
end
|
|
||||||
table.sort(nameList)
|
|
||||||
LOG(BGM.getCount().." BGM files added")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function _tryReleaseSources()
|
local function _tryReleaseSources()
|
||||||
local n=#lastLoaded
|
local n=#lastLoaded
|
||||||
while #lastLoaded>maxLoadedCount do
|
while #lastLoaded>maxLoadedCount do
|
||||||
@@ -46,6 +26,27 @@ local function _tryReleaseSources()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function _addFile(name,path)
|
||||||
|
if not SourceObjList[name]then
|
||||||
|
table.insert(nameList,name)
|
||||||
|
SourceObjList[name]={path=path,source=false}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BGM.getList()return nameList end
|
||||||
|
function BGM.getCount()return #nameList end
|
||||||
|
function BGM.load(name,path)
|
||||||
|
if type(name)=='table'then
|
||||||
|
for k,v in next,name do
|
||||||
|
_addFile(k,v)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
_addFile(name,path)
|
||||||
|
end
|
||||||
|
table.sort(nameList)
|
||||||
|
LOG(BGM.getCount().." BGM files added")
|
||||||
|
end
|
||||||
|
|
||||||
function BGM.setDefault(bgm)
|
function BGM.setDefault(bgm)
|
||||||
BGM.default=bgm
|
BGM.default=bgm
|
||||||
end
|
end
|
||||||
@@ -72,8 +73,7 @@ end
|
|||||||
local function task_fadeOut(src)
|
local function task_fadeOut(src)
|
||||||
while true do
|
while true do
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
if tostring(src):find('NULL')then return end
|
local v=src:getVolume()-volume/40
|
||||||
local v=src:getVolume()-.025*volume
|
|
||||||
src:setVolume(v>0 and v or 0)
|
src:setVolume(v>0 and v or 0)
|
||||||
if v<=0 then
|
if v<=0 then
|
||||||
src:stop()
|
src:stop()
|
||||||
@@ -85,7 +85,7 @@ local function task_fadeIn(src)
|
|||||||
while true do
|
while true do
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
local v=volume
|
local v=volume
|
||||||
v=math.min(v,src:getVolume()+.025*v)
|
v=math.min(v,src:getVolume()+v/40)
|
||||||
src:setVolume(v)
|
src:setVolume(v)
|
||||||
if v>=volume then
|
if v>=volume then
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user