API:Class/ContentProvider

Client only:This service is client-side only! You should use a LocalScript instead of a Script when using it.
Filtered-inheritance mode: While this class technically inherits all Instance class members, some (if not all) have been hidden because they serve no purpose for this object.
Service: This class is a service. It is a top-level singleton which can be obtained with the GetService method.

Cloud.pngContentProvider : Object Icon.pngInstance

The ContentProvider is used to provide content for your places. This service can be used to preload assets, and has a useful property, RequestQueueSize, which allows you to know the progress with which your assets have been preloaded.

Properties

Properties [toggle]

stringBaseUrl [readonly]

The base URL that is used for Content values.

|RMD member="API:Class/ContentProvider/BaseUrl"|The base URL that is used for Content values.|/RMD|
intRequestQueueSize [readonly]

The number of items in the request queue that need to be loaded.

|RMD member="API:Class/ContentProvider/RequestQueueSize"|The number of items in the request queue that need to be loaded.|/RMD|
BaseUrl [readonly]
The base URL that is used for Content values.
RequestQueueSize [readonly]
The number of items in the request queue that need to be loaded.

Functions

FunctionsmemberhiddenFunctions [toggle]

voidPreload ( Content contentId ) [deprecated]

Deprecated. Do not use.

|RMD member="API:Class/ContentProvider/Preload"|Deprecated. Do not use.|/RMD|
voidSetBaseUrl ( string url ) [LocalUserSecurity]

Sets BaseUrl, used by CoreScripts to interact with the web APIs.

|RMD member="API:Class/ContentProvider/SetBaseUrl"|Sets BaseUrl, used by CoreScripts to interact with the web APIs.|/RMD|
Preload ( Content contentId ) [deprecated]
Deprecated. Do not use.
SetBaseUrl ( string url ) [LocalUserSecurity]
Sets BaseUrl, used by CoreScripts to interact with the web APIs.

YieldFunctions

YieldFunctions [toggle]

voidPreloadAsync ( array<Instance> contentIdList )

Yields until all of the assets associated with the passed in Instances have loaded.

|RMD member="API:Class/ContentProvider/PreloadAsync"|Yields until all of the assets associated with the passed in Instances have loaded.|/RMD|
PreloadAsync ( array<Instance> contentIdList )
Yields until all of the assets associated with the passed in Instances have loaded.


|RMD member="API:Class/ContentProvider"|The ContentProvider is used to provide content for your places. This service can be used to preload assets, and has a useful property, RequestQueueSize, which allows you to know the progress with which your assets have been preloaded. |/RMD|


Example

This example preloads a list of assets, then effectively blocks the thread until each has finished loading.

local ContentProvider = Game:GetService("ContentProvider")
 
-- load a bunch of assets
local assets = {2253543, 2434541, 5133543, 2423433}
for _, asset in ipairs(assets) do
	ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. asset)
end
 
-- wait for them to complete
while ContentProvider.RequestQueueSize > 0 do
	wait(0.1)
end