andlua第四期(調(diào)用音樂)

local 音頻播放器=MediaPlayer()
function 播放(路徑)
音頻播放器.reset()
.setDataSource(路徑)
.prepare()
.start()
.setOnCompletionListener({
onCompletion=function()
end})
end
function 暫停(路徑)
音頻播放器.reset()
end
-----------------------------調(diào)用音樂-------------------------------
function 歌曲1.onClick()
if 歌曲1.checked==true then
播放(activity.getLuaDir("mp3/1"))
提示("正在播放你看到的我","20sp")
end
if 歌曲1.checked==false then
暫停(activity.getLuaDir("mp3/1"))
提示("已停止")
end
end
function 歌曲2.onClick()
if 歌曲2.checked==true then
播放(activity.getLuaDir("mp3/2"))
提示("正在播放遺失的心跳")
end
if 歌曲2.checked==false then
暫停(activity.getLuaDir("mp3/2"))
提示("已停止")
end
end
標(biāo)簽: