Thank you very much for the quick response! I got the Background music working to play. However, If the function calls to stop Backgroundmusic an error appears in the terminal. Unfortunately, It does not stop.
following line
ERROR: soundmgr.lua:56: audio.stop() called with unexpected parameter type
Part 1
local soundmgr = {} -- Initialize Sound Table -- Allocate one channel per sound (not best way but works for limited number of sounds) local soundTable = {} -- local lastChannel = 4 -- lastChannel = audio.findFreeChannel(lastChannel+1) soundTable.backgroundMusic = { handle = audio.loadStream("audio/080415pianobgm3popver\_0\_02.mp3"), channel = lastChannel } -- lastChannel = audio.findFreeChannel(lastChannel+1) soundTable.levelMusic = { handle = audio.loadStream("audio/Accept.mp3"), channel = lastChannel } -- lastChannel = audio.findFreeChannel(lastChannel+1) soundTable.windEffect = { handle = audio.loadSound( "audio/short\_wind\_sound.mp3" ), channel = lastChannel } -- lastChannel = audio.findFreeChannel(lastChannel+1) soundTable.enemyHit = { handle = audio.loadSound( "audio/enemy-hit.au" ), channel = lastChannel } -- -- sound.play( name [, params] ) - Play 'name' sound with optional params. -- function soundmgr.play( name, params ) params = params or {} -- if( not soundTable[name] ) then print("Warning! soundMgr.play() - Sound ", name, " not found in sound table." ) return end -- if( audio.isChannelActive( soundTable[name].channel ) ) then return end -- params.channel = soundTable[name].channel -- audio.play( soundTable[name].handle, params ) end -- -- sound.stop( name ) - Play 'name' sound if playing. -- function soundmgr.stop( name ) if( not soundTable[name] ) then print("Warning! soundMgr.stop() - Sound ", name, " not found in sound table." ) return end -- if( not audio.isChannelActive( soundTable[name].channel ) or not audio.isChannelPlaying( soundTable[name].channel ) ) then return end -- audio.seek( 0, { channel = soundTable[name].handle } ) audio.stop( soundTable[name].handle ) end return soundmgr
Part 2
local soundmgr = require "soundmgr" soundmgr.play( "backgroundMusic", { loops = 1, fadein = 1000 } ) -- stop it in 5 seconds to demo concept local myClosure = function() soundmgr.stop( "backgroundMusic" ) end timer.performWithDelay( 500, myClosure, 1 )
The music is interrupted and starts from the beginning but does not stop totally… Thanks in advance!
ERROR: soundmgr.lua:56: audio.stop() called with unexpected parameter type
My corona build is the latest one. (2017.3183)
I agree with speaking properly english. Even if im not native speaker feel free to correct me.