• Loop sound with sound.PlayFile
    4 replies, posted
Hi everyone, I tried to play clientside loop sound in local with the function sound.PlayFile() but my sound stop after ~1s play when I use EnableLooping(true). Is this function only working with no looping sounds ? I can't use surface.PlaySound because I need the function IGModAudioChannel:GetTime(). My code: [CODE] sound.PlayFile("sound/ambient/alarms/alarm_citizen_loop1.wav", "noblock", function(station, errorId, errorName) if IsValid(station) then station:EnableLooping(true) end end) [/CODE] Thanks for your help
Got the same problem here, the sound stops quickly after started playing.
Try using a timer with the exact length of the sound, heres an example in a function [CODE]function LoopSound( sound, repetitions ) timer.Create( "SoundLoopTimer", SoundDuration( sound ), repetitions, function() sound.PlayFile( sound, "mono", function( station ) if IsValid( station ) then station:Play() end end) end) end [/CODE] run it by doing LoopSound( Your Sound Path Here, Times to reapeat( 0 for loop ) ) This should work unable to test it at the moment. Ive never touched EnableLooping so i couldn't tell you if you were using it right or wrong or if it was broken.
This happens because the sound you're trying to use does not have sound cues, I believe: [url]https://wiki.garrysmod.com/page/Creating_Looping_Sounds[/url]
Both ways should work, mine being the less efficient way and his being the correct route.
Sorry, you need to Log In to post a reply to this thread.