Menu

[r331]: / trunk / framework / OSMF / org / osmf / utils / OSMFStrings.as  Maximize  Restore  History

Download this file

533 lines (427 with data), 16.0 kB

  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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
/*****************************************************
*
* Copyright 2009 Adobe Systems Incorporated. All Rights Reserved.
*
*****************************************************
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Adobe Systems Incorporated.
* Portions created by Adobe Systems Incorporated are Copyright (C) 2009 Adobe Systems
* Incorporated. All Rights Reserved.
*
*****************************************************/
package org.osmf.utils
{
import flash.utils.Dictionary;
/**
* Utility class that exposes all user-facing strings.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public class OSMFStrings
{
/**
* Returns the user-facing string for the given key. All possible keys
* are defined as static constants on this class. The parameters are
* optional substitution variables, formatted as {0}, {1}, etc.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public static function getString(key:String, params:Array=null):String
{
return resourceStringFunction(key, params);
}
/**
* Function that the getString methods uses to retrieve a user-facing string.
*
* <p>This function takes a String parameter (which is expected to be one of
* the static consts on this class) and an optional Array of parameters
* which can be substituted into the String (formatted as {0}, {1}, etc.).</p>
*
* <p>Clients can supply their own getString function to localize the strings.
* By default, the getString function returns an English-language String.</p>
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public static function get resourceStringFunction():Function
{
return _resourceStringFunction;
}
public static function set resourceStringFunction(value:Function):void
{
_resourceStringFunction = value;
}
// Runtime Errors
//
// CompositeTraitFactory
/**
* @private
**/
public static const COMPOSITE_TRAIT_NOT_FOUND:String = "compositeTraitNotFound";
// General
/**
* @private
**/
public static const INVALID_PARAM:String = "invalidParam";
/**
* @private
**/
public static const NULL_PARAM:String = "nullParam";
/**
* @private
**/
public static const FUNCTION_MUST_BE_OVERRIDDEN:String = "functionMustBeOverridden";
/**
* @private
**/
public static const ALREADY_ADDED:String = "alreadyAdded";
/**
* @private
**/
public static const UNSUPPORTED_MEDIA_ELEMENT_TYPE:String = "unsupportedMediaElementType";
// MediaElement
/**
* @private
**/
public static const TRAIT_INSTANCE_ALREADY_ADDED:String = "traitInstanceAlreadyAdded";
/**
* @private
**/
public static const TRAIT_RESOLVER_ALREADY_ADDED:String = "traitResolverAlreadyAdded";
// MediaPlayer
/**
* @private
**/
public static const CAPABILITY_NOT_SUPPORTED:String = "capabilityNotSupported";
/**
* @private
**/
public static const MEDIA_LOAD_FAILED:String = "mediaLoadFailed";
// LoadTrait
/**
* @private
**/
public static const MUST_SET_LOADER:String = "mustSetLoader";
/**
* @private
**/
public static const LOADER_CANT_HANDLE_RESOURCE:String = "loaderCantHandleResource";
// PlayTrait
/**
* @private
**/
public static const PAUSE_NOT_SUPPORTED:String = "pauseNotSupported";
// LoaderBase
/**
* @private
**/
public static const ALREADY_READY:String = "alreadyReady";
/**
* @private
**/
public static const ALREADY_LOADING:String = "alreadyLoading";
/**
* @private
**/
public static const ALREADY_UNLOADED:String = "alreadyUnloaded";
/**
* @private
**/
public static const ALREADY_UNLOADING:String = "alreadyUnloading";
// CompositeDisplayObjectTrait
/**
* @private
**/
public static const INVALID_LAYOUT_RENDERER_CONSTRUCTOR:String = "invalidLayoutRendererConstructor";
// MediaElementLayoutTarget
/**
* @private
**/
public static const ILLEGAL_CONSTRUCTOR_INVOCATION:String = "illegalConstructorInvocation";
// MediaContainer
/**
* @private
**/
public static const DIRECT_DISPLAY_LIST_MOD_ERROR:String = "directDisplayListModError";
// HTMLLoadTrait
/**
* @private
**/
public static const NULL_SCRIPT_PATH:String = "nullScriptPath";
// Dynamic Streaming
/**
* @private
**/
public static const STREAMSWITCH_INVALID_INDEX:String = "streamSwitchInvalidIndex";
// Alternative Audio
/**
* @private
**/
public static const ALTERNATIVEAUDIO_INVALID_INDEX:String = "alternativeAudioInvalidIndex";
/**
* @private
**/
public static const STREAMSWITCH_STREAM_NOT_IN_MANUAL_MODE:String = "streamSwitchStreamNotInManualMode";
// DRM
CONFIG::FLASH_10_1
{
/**
* @private
**/
public static const DRM_METADATA_NOT_SET:String = "drmMetadataNotSet";
}
// DVR
/**
* @private
**/
public static const DVR_MAXIMUM_RPC_ATTEMPTS:String = "dvrMaximumRPCAttempts";
/**
* @private
**/
public static const DVR_UNEXPECTED_SERVER_RESPONSE:String = "dvrUnexpectedServerResponse";
// Flash Media Manifest Errors
/**
* @private
**/
public static const F4M_PARSE_PROFILE_MISSING:String = "f4mProfileMissing";
/**
* @private
**/
public static const F4M_PARSE_MEDIA_URL_MISSING:String = "f4mMediaURLMissing";
/**
* @private
**/
public static const F4M_PARSE_BITRATE_MISSING:String = "f4mBitrateMissing";
/**
* @private
**/
public static const F4M_PARSE_VALUE_MISSING:String = "f4mValueMissing";
/**
* @private
**/
public static const F4M_PARSE_ERROR:String = "f4mParseError";
// MediaErrorCodes
/**
* @private
**/
public static const IO_ERROR:String = "ioError";
/**
* @private
**/
public static const SECURITY_ERROR:String = "securityError";
/**
* @private
**/
public static const ASYNC_ERROR:String = "asyncError";
/**
* @private
**/
public static const ARGUMENT_ERROR:String = "argumentError";
/**
* @private
**/
public static const URL_SCHEME_INVALID:String = "urlSchemeInvalid";
/**
* @private
**/
public static const HTTP_GET_FAILED:String = "httpGetFailed";
/**
* @private
**/
public static const PLUGIN_VERSION_INVALID:String = "pluginVersionInvalid";
/**
* @private
**/
public static const PLUGIN_IMPLEMENTATION_INVALID:String = "pluginImplementationInvalid";
/**
* @private
**/
public static const SOUND_PLAY_FAILED:String = "soundPlayFailed";
/**
* @private
**/
public static const NETCONNECTION_REJECTED:String = "netConnectionRejected";
/**
* @private
**/
public static const NETCONNECTION_APPLICATION_INVALID:String = "netConnectionApplicationInvalid";
/**
* @private
**/
public static const NETCONNECTION_FAILED:String = "netConnectionFailed";
/**
* @private
**/
public static const NETCONNECTION_TIMEOUT:String = "netConnectionTimeout";
/**
* @private
**/
public static const NETSTREAM_PLAY_FAILED:String = "netStreamPlayFailed";
/**
* @private
**/
public static const NETSTREAM_STREAM_NOT_FOUND:String = "netStreamStreamNotFound";
/**
* @private
**/
public static const NETSTREAM_FILE_STRUCTURE_INVALID:String = "netStreamFileStructureInvalid";
/**
* @private
**/
public static const NETSTREAM_NO_SUPPORTED_TRACK_FOUND:String = "netStreamNoSupportedTrackFound";
/**
* @private
**/
public static const DRM_SYSTEM_UPDATE_ERROR:String = "drmSystemUpdateError";
/**
* @private
**/
public static const DVRCAST_SUBSCRIBE_FAILED:String = "dvrCastSubscribeFailed";
/**
* @private
**/
public static const DVRCAST_CONTENT_OFFLINE:String = "dvrCastContentOffline";
/**
* @private
**/
public static const DVRCAST_STREAM_INFO_RETRIEVAL_FAILED:String = "dvrCastStreamInfoRetrievalFailed";
/**
* @private
**/
public static const MULTICAST_PARAMETER_INVALID:String = "multicastParameterInvalid";
/**
* @private
**/
public static const MULTICAST_NOT_SUPPORT_MBR:String = "multicastNotSupportMBR";
/**
* @private
**/
public static const F4M_FILE_INVALID:String = "f4MFileINVALID";
/**
* @private
**/
public static const F4M_MEDIA_MISSING:String = "f4mMediaMissing";
private static const resourceDict:Dictionary = new Dictionary();
{
resourceDict[COMPOSITE_TRAIT_NOT_FOUND] = "There is no composite trait for the given trait type";
resourceDict[INVALID_PARAM] = "Invalid parameter passed to method";
resourceDict[NULL_PARAM] = "Unexpected null parameter passed to method";
resourceDict[FUNCTION_MUST_BE_OVERRIDDEN] = "Function must be overridden";
resourceDict[ALREADY_ADDED] = "Child has already been added";
resourceDict[UNSUPPORTED_MEDIA_ELEMENT_TYPE] = "The specified media element type is not supported";
resourceDict[TRAIT_INSTANCE_ALREADY_ADDED] = "An instance of this trait class has already been added to this MediaElement";
resourceDict[TRAIT_RESOLVER_ALREADY_ADDED] = "A trait resolver for the specified trait type has already been added to this MediaElement";
resourceDict[CAPABILITY_NOT_SUPPORTED] = "The specified capability is not currently supported";
resourceDict[MEDIA_LOAD_FAILED] = "The loading of a MediaElement failed";
resourceDict[MUST_SET_LOADER] = "Must set LoaderBase on a LoadTrait before calling load or unload";
resourceDict[LOADER_CANT_HANDLE_RESOURCE] = "LoaderBase unable to handle the given MediaResourceBase";
resourceDict[PAUSE_NOT_SUPPORTED] = "PlayTrait.pause cannot be invoked when canPause is false";
resourceDict[ALREADY_READY] = "Loader - attempt to load an already loaded object";
resourceDict[ALREADY_LOADING] = "Loader - attempt to load a loading object";
resourceDict[ALREADY_UNLOADED] = "Loader - attempt to unload an already unloaded object";
resourceDict[ALREADY_UNLOADING] = "Loader - attempt to unload a unloading object";
resourceDict[INVALID_LAYOUT_RENDERER_CONSTRUCTOR] = "Unable to construct LayoutRenderer implementation";
resourceDict[ILLEGAL_CONSTRUCTOR_INVOCATION] = "Use the static getInstance method to obtain a class instance";
resourceDict[DIRECT_DISPLAY_LIST_MOD_ERROR] = "The direct addition or removal of display objects onto a MediaContainer is prohibited.";
resourceDict[NULL_SCRIPT_PATH] = "Operation requires a valid script path";
resourceDict[STREAMSWITCH_INVALID_INDEX] = "Dynamic Stream Switching - Invalid index requested";
resourceDict[STREAMSWITCH_STREAM_NOT_IN_MANUAL_MODE] = "Dynamic Stream Switching - stream is not in manual mode";
resourceDict[ALTERNATIVEAUDIO_INVALID_INDEX] = "Alternative Audio Source Changing - Invalid index requested";
CONFIG::FLASH_10_1
{
resourceDict[DRM_METADATA_NOT_SET] = "Metadata not set on DRMServices";
}
resourceDict[DVR_MAXIMUM_RPC_ATTEMPTS] = "Maximum DVRGetStreamInfo RPC attempts (%i) reached";
resourceDict[DVR_UNEXPECTED_SERVER_RESPONSE] = "Unexpected server response: ";
resourceDict[F4M_PARSE_PROFILE_MISSING] = "Profile missing from Bootstrap info tag";
resourceDict[F4M_PARSE_MEDIA_URL_MISSING] = "URL missing from Media tag";
resourceDict[F4M_PARSE_BITRATE_MISSING] = "Bitrate missing from Media tag";
resourceDict[F4M_PARSE_VALUE_MISSING] = "Value must be non-null";
resourceDict[F4M_PARSE_ERROR] = "Error parsing f4m file";
resourceDict[IO_ERROR] = "I/O error when loading media";
resourceDict[SECURITY_ERROR] = "Security error when loading media";
resourceDict[ASYNC_ERROR] = "Async error when loading media";
resourceDict[ARGUMENT_ERROR] = "Argument error when loading media";
resourceDict[URL_SCHEME_INVALID] = "Invalid URL scheme";
resourceDict[HTTP_GET_FAILED] = "HTTP GET failed due to a Client Error (4xx Status Code)";
resourceDict[PLUGIN_VERSION_INVALID] = "Plugin failed to load due to version mismatch";
resourceDict[PLUGIN_IMPLEMENTATION_INVALID] = "Plugin failed to load due to improper or missing implementation of PluginInfo";
resourceDict[SOUND_PLAY_FAILED] = "Playback failed due to no sound channels being available";
resourceDict[NETCONNECTION_REJECTED] = "Connection attempt rejected by FMS server";
resourceDict[NETCONNECTION_APPLICATION_INVALID] = "Attempting to connect to an invalid FMS application";
resourceDict[NETCONNECTION_FAILED] = "All NetConnection attempts failed";
resourceDict[NETCONNECTION_TIMEOUT] = "Timed-out trying to establish a NetConnection, or timed out due to an idle NetConnection";
resourceDict[NETSTREAM_PLAY_FAILED] = "Playback failed";
resourceDict[NETSTREAM_STREAM_NOT_FOUND] = "Stream not found";
resourceDict[NETSTREAM_FILE_STRUCTURE_INVALID] = "File has invalid structure";
resourceDict[NETSTREAM_NO_SUPPORTED_TRACK_FOUND] = "No supported track found";
resourceDict[DRM_SYSTEM_UPDATE_ERROR] = "The update of the DRM subsystem failed";
resourceDict[DVRCAST_SUBSCRIBE_FAILED] = "DVRCast subscribe failed";
resourceDict[DVRCAST_CONTENT_OFFLINE] = "DVRCast content is offline and unavailable";
resourceDict[DVRCAST_STREAM_INFO_RETRIEVAL_FAILED] = "Unable to retrieve DVRCast stream info";
resourceDict[MULTICAST_PARAMETER_INVALID] = "The groupspec or streamName is null or empty but not both";
resourceDict[MULTICAST_NOT_SUPPORT_MBR] = "Multicast does not support MBR";
resourceDict[F4M_FILE_INVALID] = "The F4M document contains errors";
resourceDict[F4M_MEDIA_MISSING] = "The F4M document doesn't contain media informations.";
resourceDict["missingStringResource"] = "No string for resource {0}";
}
private static function defaultResourceStringFunction(resourceName:String, params:Array=null):String
{
var value:String = resourceDict.hasOwnProperty(resourceName) ? String(resourceDict[resourceName]) : null;
if (value == null)
{
value = String(resourceDict["missingStringResource"]);
params = [resourceName];
}
if (params)
{
value = substitute(value, params);
}
return value;
}
private static function substitute(value:String, ... rest):String
{
var result:String = "";
if (value != null)
{
result = value;
// Replace all of the parameters in the value string.
var len:int = rest.length;
var args:Array;
if (len == 1 && rest[0] is Array)
{
args = rest[0] as Array;
len = args.length;
}
else
{
args = rest;
}
for (var i:int = 0; i < len; i++)
{
result = result.replace(new RegExp("\\{"+i+"\\}", "g"), args[i]);
}
}
return result;
}
private static var _resourceStringFunction:Function = defaultResourceStringFunction;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.