Controlling Audio With Icons

Controlling Audio With Icons

you can download the following sample which button to show ‘stop audio button’ or ‘start audio button’ by detecting audio playing when the page switches.

It contains a sample BGM koto_bgm.mp3. It plays in all pages when each page starts

Let’s make audio control with play/stop buttons

Now use an external code to detect audio playing or not.

mycode.lua uses timer with 50 msec to detect the audio playing or not. It is a race case of detecting or audio playing which is faster when the app starts.

timer.performWithDelay(50, function()
    if audio.isChannelPlaying(1) then
        layer.audioOff.alpha = 1
        layer.audioOn.alpha = 0
        layer.audioOff.alpha = 0
        layer.audioOn.alpha = 1

Accessing each layer

as you see the code above. Each layer on page is stored in the layer table. layer.audioOff and layer.audioOn are displayObjects of Solar2D.

please visit for more information about the API.