Lua-Audio.stop()工作不正常

Lua-Audio.stop()工作不正常,lua,coronasdk,Lua,Coronasdk,我的音频有个大问题。停止() 当我调用它时,下一个音频将被调用 我想在更换场景之前停止所有音频 但当下一个音频开始在下一个场景中播放时,它就不起作用了。 这是我的代码,这样我可以更好地解释 这里我开始第一个音频文件 function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then narrativeChan

我的音频有个大问题。停止() 当我调用它时,下一个音频将被调用 我想在更换场景之前停止所有音频 但当下一个音频开始在下一个场景中播放时,它就不起作用了。 这是我的代码,这样我可以更好地解释

这里我开始第一个音频文件

function scene:show( event )
    local sceneGroup = self.view
    local phase = event.phase
    if phase == "will" then 
        narrativeChannel = audio.play( audio1, { channel=5, onComplete=NarrationStart } )
    elseif phase == "did" then

    end
end

NarrationStart = function (  )
        narrativeTimer = timer.performWithDelay( 100,function (  )
            catBubble.isVisible = true
            catText.isVisible = true
            transition.from(catText, {time = 400,alpha = 0,y = catText.y - 15, onComplete = function ()
        narrativeChannel = audio.play( audio2, { channel=5}) end })
end, 1 )
这就是我阻止它的地方

function scene:hide( event )
    local sceneGroup = self.view

    local phase = event.phase

    if event.phase == "will" then
        if(narrativeChannel ~= nil) then
            audio.stop( ) 
            print("stoped") --gets call
        end
        transition.cancel()
        if(narrativeTimer ~= nil)then timer.cancel( narrativeTimer ) end 
    elseif phase == "did" then
        -- Called when the scene is now off screen
    end 

end
当我在播放第一个audio1时更改场景时,第一个音频停止,但紧接着audio2开始。。。 我不知道为什么会这样。 请告诉我如何解决这个问题的想法或建议。 我尝试了audio.stop(),audio.stop(已使用) 没有任何东西会继续播放下一个音频,我不想这样

提前谢谢

信息:场景管理器:作曲家
Corona构建:版本2014.2463(2014.10.14)

Albert是正确的,转换.cancel()确实不会取消
onComplete

您可以添加一个变量,如
isAudioOn
,并在停止音频时将其设置为false。这样,您就可以在
onComplete
中检查该变量

NarrationStart = function (  )
        if(isAudioOn) then
            narrativeTimer = timer.performWithDelay( 100,function (  )
            catBubble.isVisible = true
            catText.isVisible = true
            transition.from(catText, {time = 400,alpha = 0,y = catText.y - 15, onComplete = function () narrativeChannel = audio.play( audio2, { channel=5}) end })
        end
end, 1 )

您是否尝试过放置
音频.停止(旁白频道)
?也许把他们放到另一个渠道是隔离问题的好方法

请参阅
transition.from(catText,{time=400,alpha=0,y=catText.y-15,onComplete=function(),叙事频道=audio.play(audio2,{channel=5})end})
我认为
transition.cancel()
不会停止
onComplete
函数,您可以在
onComplete
函数上打印内容,好吗?谢谢!我不知道。这将解决问题。