Advertisement
alestane

Revised sound play class

Mar 29th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Track = {}
  2. function Track:new()
  3.     Track.instanceTable = {
  4.         [1] = {
  5.             trackSnd = audio.loadStream( "Sound/Tracks/01.mp3" ),
  6.             trackVolume = 100,
  7.             trackName = "track_01.mp3",
  8.             trackStart = {  
  9.                 [1] = {5000, 1000},
  10.                 [2] = {15000, 1000},
  11.             },
  12.         },
  13.     }
  14.  
  15.  
  16.     function Track:play( track, trackBegin )
  17.         Track.activeTrack = track
  18.         track = Track.instanceTable[track]
  19.         local snd = track.trackSnd
  20.         local begin, stop = unpack(track.trackStart[trackBegin], 1, 2 )
  21.         local seek = audio.seek(begin, snd)
  22.         local c = audio.play(snd)
  23.         audio.stopWithDelay(stop, c)                    
  24.     end            
  25. end
  26. return Track
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement