Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 20 Oct 2014 06:13 PM |
Whenever I start a new audio for the first time, there's a large lag spike. My entire screen freezes for a few seconds.
I tried preloading the sounds, but it did not makes a difference.
I was wondering if there was any way to prevent this lag. I will not post my code, because it works fine, all I need to know is if this is possible, and if so how to do it. |
|
|
| Report Abuse |
|
|
| |
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
| |
|
|
| 21 Oct 2014 08:49 AM |
Try preloading them.
http://wiki.roblox.com/index.php?title=Preload |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2014 09:03 AM |
@builderman: "I tried preloading the sounds, but it did not makes a difference."
Read before you post.
-The [Guy] |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 21 Oct 2014 09:14 AM |
| You can "fake" preload them by playing and immediately pausing them all when the player joins. This will cause the client to load them in even though the song doesn't have enough time to actually play. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 21 Oct 2014 10:12 AM |
You need to make sure that the computer like, actually caches them properly (Ready to read instead of being ready downloaded), otherwise the lag caused will probably be from the reading of the file (It holds up the main thread until it's done)
Something like that anyway, if it's anything like stuff I've used in the past |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 21 Oct 2014 11:00 AM |
Preloading them does make a difference, if it's still lagging, you're either not preloading correctly or you have a terrible processor. -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2014 01:16 PM |
@Busy He obviously didn't do it right, lrn2swag before you post. |
|
|
| Report Abuse |
|
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 21 Oct 2014 03:02 PM |
I didn't do it right??? Here's my code. It's a server script inside of ServerScriptServer. All the ID's are correct.
It actually DOES make a difference when I do it on Play Solo, but I still get the huge lag spike when I play online.
local assets = {144941795,163233363,178847457} for _, asset in ipairs(assets) do game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset) end |
|
|
| Report Abuse |
|
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 21 Oct 2014 03:09 PM |
| Actually with more tests I get the huge spike in PlaySolo as well. |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 21 Oct 2014 03:23 PM |
| Try using my idea. It works in my game as I had the same problem with preload. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 21 Oct 2014 05:39 PM |
Are you playing the songs immediately? All preload does is queue them in roblox's content loader. It doesn't actually load them. It'd be the same as playing the audio, it'd freeze the game until the client successfully downloaded the asset. In other words, if you're not waiting for it to finish loading, it's gonna do this. lol
-=Robo=- |
|
|
| Report Abuse |
|
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 22 Oct 2014 09:26 AM |
@robocu No I'm waiting a few seconds to allow them to preload.
@tinarg That seems to work but when I do
sound:Play() sound:Pause()
sometimes it doesn't pause. I'm not sure why, but maybe it's changing it so fast that it doesn't pause correctly. I tried putting a wait() between the lines, but then you can hear the sounds a little before they're stopped again. It does get rid of the lag spike though. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Oct 2014 09:47 AM |
'I didn't do it right??? Here's my code. It's a server script inside of ServerScriptServer. All the ID's are correct.'
that's your problem |
|
|
| Report Abuse |
|
|
Looah
|
  |
| Joined: 22 Feb 2013 |
| Total Posts: 922 |
|
|
| 22 Oct 2014 09:48 AM |
^ do it in a localscript m8 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Looah
|
  |
| Joined: 22 Feb 2013 |
| Total Posts: 922 |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 22 Oct 2014 10:03 AM |
| Unfortunately putting that same code in a LocalScript in StarterGui didn't make a difference with the lag. |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2014 10:16 AM |
http://wiki.roblox.com/index.php?title=API:Class/ContentProvider/Preload
Read the note
"And how high can you fly with broken wings? " - Aerosmith |
|
|
| Report Abuse |
|
|
| |
|
Perci1
|
  |
| Joined: 24 Jan 2011 |
| Total Posts: 1027 |
|
|
| 22 Oct 2014 03:18 PM |
Well tinarg's idea ended up working the best. I just don't think preloading is getting me anywhere.
Thanks for all the help, everyone. |
|
|
| Report Abuse |
|
|