Corona sdk:当另一个启动时停止音频/仅启动一次音频

Corona sdk : stop audio when another starts / launch audio just once

我想在另一个开始播放时停止声音。

if (event.object1.myName == "obst3") then 
audio.play(colsound)

如果下一个开始,我希望这个停止。

if (event.object1.myName == "t") then
    audio.play(explosion) 

此外,我需要知道如何只发出一次声音(当我的物体与墙壁碰撞时,会弹出一个声音,我需要这个声音只被听到一次,即使玩家再次触摸墙壁也是如此。

播放每个具有参考 id 值的音频:

    if (event.object1.myName == "obst3") then 
       local isChannel1Playing = audio.isChannelPlaying( 2 )
       if isChannel1Playing then
         audio.stop( playLaserSound2 )
         playLaserSound2 = nil
       end
       playLaserSound1  = audio.play(colsound, { channel=1 })
    end
   if (event.object1.myName == "t") then
      local isChannel1Playing = audio.isChannelPlaying( 1 )
       if isChannel1Playing then
         audio.stop( playLaserSound1 )
         playLaserSound1 = nil
       end
      playLaserSound2 = audio.play(explosion, { channel=2 })
   end