Advertisement
lvs

Untitled

lvs
Feb 11th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local audioChannel, otherAudioChannel, currentSong, curAudio, prevAudio = 1
  2. audio.crossFadeBackground = function (path, force)
  3.         local musicPath = path
  4.         if currentSong == musicPath and audio.getVolume{channel = audioChannel} > 0.1 and not force then return false end
  5.         audio.fadeOut({channel=audioChannel, time=1000})
  6.         if audioChannel==1 then audioChannel,otherAudioChannel=2,1 else audioChannel,otherAudioChannel=1,2 end
  7.         audio.setVolume( 1, {channel = audioChannel})
  8.         curAudio = audio.loadStream( musicPath )
  9.         audio.play(curAudio, {channel=audioChannel, loops=-1, fadein=1000})
  10.         prevAudio = curAudio
  11.         currentSong = musicPath
  12.         audio.currentBackgroundChannel = audioChannel
  13. end
  14. audio.reserveChannels(2)
  15. audio.currentBackgroundChannel = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement