alestane icon

Revised sound play class

alestane | PRO | 03/29/14 08:19:01 PM UTC | 0 ⭐ | 346 👁️ | Never ⏰ | []
Lua |

630 B

|

None

|

0 👍

/

0 👎

Track = {}
function Track:new()
    Track.instanceTable = {
        [1] = {
            trackSnd = audio.loadStream( "Sound/Tracks/01.mp3" ), 
            trackVolume = 100,
            trackName = "track_01.mp3",
            trackStart = {  
                [1] = {5000, 1000},
                [2] = {15000, 1000},
            },
        },
    }
 
 
    function Track:play( track, trackBegin )
        Track.activeTrack = track
        track = Track.instanceTable[track]
        local snd = track.trackSnd
        local begin, stop = unpack(track.trackStart[trackBegin], 1, 2 )
        local seek = audio.seek(begin, snd)
        local c = audio.play(snd)
        audio.stopWithDelay(stop, c)                    
    end            
end
return Track

Comments