–outside the scene functions
local music = audio.loadStream(“Automation.mp3”)
local mute
local unmute
–inside the function scene:show( event ), phase == will
mute = display.newImageRect(“Music 4.png”, aCW/5, aCW/5)
mute.x = cW - (cX/3)
mute.y = cSY + cY/8
unmute = display.newImageRect(“Music cancel 4.png”, aCW/6, aCW/6)
unmute.x = cW - (cX/3)
unmute.y = cSY + cY/8
unmute.isVisible = false
–inside the function scene:show( event ), phase == did
local function muteSound()
audio.pause(music)
mute.isVisible = false
unmute.isVisible = true
end
local function unMuteSound()
audio.resume(music)
mute.isVisible = true
unmute.isVisible = false
end
mute:addEventListener(“tap”, muteSound)
unmute:addEventListener(“tap”, unMuteSound)