/
ContentProvider.yaml
337 lines (328 loc) · 10.1 KB
/
ContentProvider.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
name: ContentProvider
type: class
category: Data
memory_category: Instances
summary: |
Service that is used to load content, or assets, into a game.
description: |
Service that is used to load content, or assets, into a game.
The service's main use is to preload assets into a game. When a new asset such
as a `Class.Decal` or `Class.Sound` is used in a game, Roblox will load the
content associated with it from Roblox servers. In some cases, this can be
undesirable for developers as it can lead to a delay before the content loads
into the game.
With ContentProvider, developers can preload assets using the
`Class.ContentProvider:PreloadAsync()` function. Another useful property is
`Class.ContentProvider.RequestQueueSize`, which can be used to measure what
proportion of assets in the request queue have been downloaded.
code_samples:
- ContentProvider1
inherits:
- Instance
tags:
- NotCreatable
- Service
- NotReplicated
deprecation_message: ''
properties:
- name: ContentProvider.BaseUrl
summary: |
Used by the `Class.ContentProvider` to download assets from the Roblox
website.
description: |
Used by the `Class.ContentProvider` to download assets from the Roblox
website.
This URL points to a Roblox hosted website from which assets are
downloaded and is pulled from the AppSettings.xml file, located in the
version-hash folder.
It is possible to overwrite this property using the
`Class.ContentProvider:SetBaseUrl()` function in the command bar; however,
this is not recommended and may cause asset loading issues.
code_samples:
type: string
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: true
- name: ContentProvider.RequestQueueSize
summary: |
Gives the number of items in the `Class.ContentProvider` request queue
that need to be downloaded.
description: |
Gives the number of items in the `Class.ContentProvider` request queue
that need to be downloaded.
Items are added to the client's request queue when an asset is used for
the first time or `Class.ContentProvider:PreloadAsync()` is called.
Developers are advised not to use RequestQueueSize to create loading bars.
This is because the queue size can both increase and decrease over time as
new assets are added and downloaded. Developers looking to display loading
progress should load assets one at a time (see example below).
code_samples:
- ContentProvider-Loading-Bar
type: int
tags:
- ReadOnly
- NotReplicated
deprecation_message: ''
security:
read: None
write: None
thread_safety: ReadSafe
category: Data
serialization:
can_load: false
can_save: true
methods:
- name: ContentProvider:GetAssetFetchStatus
summary: |
Gets the current `Enum.AssetFetchStatus` of the `contentId` provided.
description: |
Gets the current `Enum.AssetFetchStatus` of the `contentId` provided. Use
`Class.ContentProvider:GetAssetFetchStatusChangedSignal()|GetAssetFetchStatusChangedSignal()`
to listen for changes to this value.
code_samples:
- ContentProvider-GetAssetFetchStatus1
parameters:
- name: contentId
type: Content
default:
summary: |
The ID of the content to fetch the status for.
returns:
- type: AssetFetchStatus
summary: |
The `Enum.AssetFetchStatus` of the content.
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:GetAssetFetchStatusChangedSignal
summary: |
A signal that fires when the `Enum.AssetFetchStatus` of the provided
content changes.
description: |
A signal that fires when the `Enum.AssetFetchStatus` of the provided
content changes. Connect to this signal by using a callback with one
argument of type `Enum.AssetFetchStatus`. This is particularly useful for
assets that might update themselves automatically like the thumbnail of a
user when they change clothes.
code_samples:
- ContentProvider-GetAssetFetchStatus1
parameters:
- name: contentId
type: Content
default:
summary: ''
returns:
- type: RBXScriptSignal
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:ListEncryptedAssets
summary: ''
description: ''
code_samples:
parameters: []
returns:
- type: Array
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:Preload
summary: |
Queues an asset to be downloaded by the `Class.ContentProvider`.
description: |
Usually, content is loaded only when it starts being used. That explains
why it often takes a moment for an image to appear in a
`Class.GuiObject|GUI`, or a `Mesh|mesh` to appear in a
`Class.BasePart|part`, or why a `Class.Sound|sound` doesn't play for the
first time. All because the asset has not yet finished loading. Preload is
used to load this content beforehand, so that it works instantly.
code_samples:
- ContentProvider-Preload1
parameters:
- name: contentId
type: Content
default:
summary: ''
returns:
- type: void
summary: ''
tags:
- Deprecated
deprecation_message: |
This item has been superseded by `Class.ContentProvider:PreloadAsync()`
which should be used in all new work.
security: None
thread_safety: Unsafe
- name: ContentProvider:RegisterDefaultEncryptionKey
summary: ''
description: ''
code_samples:
parameters:
- name: encryptionKey
type: string
default:
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:RegisterDefaultSessionKey
summary: ''
description: ''
code_samples:
parameters:
- name: sessionKey
type: string
default:
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:RegisterEncryptedAsset
summary: ''
description: ''
code_samples:
parameters:
- name: assetId
type: Content
default:
summary: ''
- name: encryptionKey
type: string
default:
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:RegisterSessionEncryptedAsset
summary: ''
description: ''
code_samples:
parameters:
- name: contentId
type: Content
default:
summary: ''
- name: sessionKey
type: string
default:
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:UnregisterDefaultEncryptionKey
summary: ''
description: ''
code_samples:
parameters: []
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:UnregisterEncryptedAsset
summary: ''
description: ''
code_samples:
parameters:
- name: assetId
type: Content
default:
summary: ''
returns:
- type: void
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
- name: ContentProvider:PreloadAsync
summary: |
Yields until all of the assets associated with the given
`Class.Instance|Instances` have loaded.
description: |
Yields until all of the assets associated with the given
`Class.Instance|Instances` have loaded. This can be used to pause a script
and not use content until it is certain that the content has been loaded
into the experience.
When called, the engine identifies links to content for each item in the
list. For any of the `Class.Instance|Instances` which have properties that
define links to content, such as a `Class.Decal|Decal` or a
`Class.Sound|Sound`, the engine attempts to load these assets from Roblox.
For each requested asset, the callback function runs, indicating the
asset's final `Enum.AssetFetchStatus`.
This method can also take in a list of content ID strings, however these
strings must correspond to **image** assets. Attempting to load non-image
assets through the use of their content ID strings will result in failure.
If any of the assets fail to load, an error message appears in the output.
The method itself will not error and it will continue executing until it
has processed each requested instance or asset ID.
code_samples:
- ContentProvider-PreloadAsync1
parameters:
- name: contentIdList
type: Array
default:
summary: |
An array of instances or content ID strings (for images) to load.
- name: callbackFunction
type: Function
default: nil
summary: |
The function called when each asset request completes. Returns the
`Datatype.Content|content` string and the asset's final
`Enum.AssetFetchStatus`.
returns:
- type: void
summary: ''
tags:
- Yields
deprecation_message: ''
security: None
thread_safety: Unsafe
events:
- name: ContentProvider.AssetFetchFailed
summary: ''
description: ''
code_samples:
parameters:
- name: assetId
type: Content
default:
summary: ''
tags: []
deprecation_message: ''
security: None
thread_safety: Unsafe
callbacks: []