Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local audioChannel, otherAudioChannel, currentSong, curAudio, prevAudio = 1
- audio.crossFadeBackground = function (path, force)
- local musicPath = path
- if currentSong == musicPath and audio.getVolume{channel = audioChannel} > 0.1 and not force then return false end
- audio.fadeOut({channel=audioChannel, time=1000})
- if audioChannel==1 then audioChannel,otherAudioChannel=2,1 else audioChannel,otherAudioChannel=1,2 end
- audio.setVolume( 1, {channel = audioChannel})
- curAudio = audio.loadStream( musicPath )
- audio.play(curAudio, {channel=audioChannel, loops=-1, fadein=1000})
- prevAudio = curAudio
- currentSong = musicPath
- audio.currentBackgroundChannel = audioChannel
- end
- audio.reserveChannels(2)
- audio.currentBackgroundChannel = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement