Runtime class
The entry point for all interactions with the Oooh framework. A single instance of this class is available via Instance.
Signature:
export declare class Runtime extends ExternalObject
Extends: ExternalObject
Remarks
The minimum requirement to integrate with the application is to call Runtime.ready() on the instance of this class to start the experience and Runtime.completeModule() to finish it.
The data for all accessors is available immediately as the page loads.
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Runtime
class.
Properties
Methods
Method | Modifiers | Description |
---|---|---|
adjustViewport(width, height, scale) | Change viewport settings for the iFrame the page lives in. NOTE: user-scalable will always be false, and cannot be adjusted. | |
completeModule(moduleResults) | Completes the execution of a module. Closes the module. | |
constrainView(left, top, width, height) | Change the size of the iframe the page lives in. | |
createGameTimer() | Create a GameTimer object that can be used to control a ReplayRecorder or a ReplayPlayer | |
createLayout(layout, configs, components, transitions) | Create a layout to arrange camera and video components on the screen | |
createReplayAssetCollection() | Create a new ReplayDataAssetCollection that can be used to save multiple replay data recordings as a single output asset | |
createReplayRecorder(timer) | Create a new ReplayRecorder object that can be used to record a session of game play events | |
createVideoAssetCollection() | Create a new VideoAssetCollection that can be used to save multiple videos as a single output asset | |
getAmazonService() | Get the Amazon service used to connect to the Amazon API | |
getAnalyticService() | Get the AnalyticService for BI logging. | |
getAssetManager() | Get the AssetManager used to manage input and output assets and submission data | |
getAudioManager() | Get the AudioManager used to play sound effects and music. | |
getConfigValue(key) | Lookup data statically configured for this module | |
getContextDataService() | Get data about the context the module is running within. | |
getControlManager() | Get the control manager used to modify aspect of the device. | |
getFullScreenRecorder() | Get the full screen recorder to be used to capture the full module experience to a video file | |
getFunctionService() | Get the function service used to call module cloud functions | |
getInputAsset(name) | Get an asset that has been passed from the framework into the module, available on startup | |
getInputManager() | Get the input manger used to access API features like face and body tracking. | |
getLayoutManager() | Get the LayoutManager used to control the display of Oooh rendered components like Camera, and Video. | |
getLocalNotificationService() | Get the local notification service used to schedule local notifications | |
getMediaSourceManager() | Get the MediaSourceManager for creating camera and video media sources. | |
getNativeUIManager() | Get the native UI manger for use with native controls like the native record button. | |
getOoohMetadataService() | Get the oooh metadata service which can be used to get information about the oooh instance. | |
getPauseSubject() | Be notified when module execution is paused | |
getSystemSettingsService() | Get the system settings service for getting updates on system settings. | |
getTwitchService() | Get the Twitch service used to connect to the Twitch API | |
getUserDataService() | Get the user profile service used to fetch information about the active user and the creator of the Oooh. | |
getUserPersistentDataService() | Get the user persistent data service used to fetch custom data stored globally about the module or specific to the instance of the Oooh. | |
openExternalLink(url) | Open an external link to a webpage in the in-app browser | |
ready(callback) | Your experience must call this when it is fully loaded and ready to start the user experience. |
Runtime.adjustViewport() method
Change viewport settings for the iFrame the page lives in. NOTE: user-scalable will always be false, and cannot be adjusted.
Signature:
adjustViewport(width?: string, height?: string, scale?: string): void;
Parameters
Parameter | Type | Description |
---|---|---|
width | string | (Optional) The iFrame's viewport width setting. Valid values are "device-width", a numeric value including units or percent, e.g. "600px", or undefined. Setting to undefined will cause the parameter to not be added to the meta:viewport tag. |
height | string | (Optional) The iFrame's viewport height setting. Valid values are "device-height", a numeric value including units or percent, e.g. "600px", or undefined. Setting to undefined will cause the parameter to not be added to the meta:viewport tag. |
scale | string | (Optional) The will be used to set the iFrame's content:initial-scale, minimum-scale, and maximum-scale settings. Setting to undefined will cause the parameters to not be added to the meta:viewport tag. |
Returns:
void
Runtime.completeModule() method
Completes the execution of a module. Closes the module.
Signature:
completeModule(moduleResults: ModuleResults | number): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
moduleResults | ModuleResults | number | Conditions that describe the state of the module when closing, including player score if applicable. The score or error code can also be passed directly as a number. |
Returns:
Promise<void>
A promise that will resolve if ModuleResults.replayable is set to true and the user returns to the module to replay it. If the user ends the experience without replaying or if ModuleResults.replayable is false, the module will be closed without the promise being resolved.
Remarks
If this is called with ModuleResults.replayable set to true in moduleResults
:
- The module will be paused and all JS execution will be suspended until the user triggers a replay or closes the module.
- If a video or audio recorder (MediaSourceRecorder, FullScreenRecorder or MicrophoneRecorder) is recording, the recording will be stopped and discarded. The recorder can be used to start a new recording if the user returns to the module.
- All camera media sources will stop capturing the camera until the user returns to the module. The camera may take some time to start after the module is resumed, you can use CameraMediaSource.getCameraRunningStateUpdates() to determine when the camera is running.
Example
// Submit a score, and close the module. Do not submit the score without object notation.
runtime.completeModule({ score: 1000 });
Runtime.constrainView() method
Change the size of the iframe the page lives in.
Signature:
constrainView(left: number, top: number, width: number, height: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
left | number | The css pixels to leave as padding to the left of the iframe |
top | number | The css pixels to leave as padding above the iframe |
width | number | The css pixel width of the iframe |
height | number | The css pixel height of the iframe |
Returns:
void
Remarks
Resizing your content is a more desirable solution, this exists to help with porting some legacy application.
Runtime.createGameTimer() method
Create a GameTimer object that can be used to control a ReplayRecorder or a ReplayPlayer
Signature:
createGameTimer(): Promise<GameTimer>;
Returns:
Promise<GameTimer>
Runtime.createLayout() method
Warning: This API is now obsolete.
Use LayoutManager.createLayout instead
Create a layout to arrange camera and video components on the screen
Signature:
createLayout(layout: string | LayoutCustomConfig, configs: ReadonlyObjectMap<ComponentConfig>, components?: ReadonlyObjectMap<Component>, transitions?: ReadonlyObjectMap<Transition>): Promise<Layout>;
Parameters
Parameter | Type | Description |
---|---|---|
layout | string | LayoutCustomConfig | The identifier of one of ooohs predefined layouts or a custom layout object, used to control the screen positioning of the components |
configs | ReadonlyObjectMap<ComponentConfig> | Key matching the layout element id, Value defining the type of component to show in that layout element and it's options |
components | ReadonlyObjectMap<Component> | (Optional) Existing components to be placed in the layout element id matched by key. If this is supplied then the config value for the same key will be ignored |
transitions | ReadonlyObjectMap<Transition> | (Optional) Allow existing components to move from their old position to new position over time. Only the time and function properties of the Transition object are applied. |
Returns:
Promise<Layout>
The layout once it's able to be made visible
Remarks
When creating a camera, or loading a video, this call can take more than half a second to run, try to perform this operation behind the scenes
Runtime.createReplayAssetCollection() method
Warning: This API is now obsolete.
Use same method on AssetManager
Create a new ReplayDataAssetCollection that can be used to save multiple replay data recordings as a single output asset
Signature:
createReplayAssetCollection(): Promise<ReplayDataAssetCollection>;
Returns:
Promise<ReplayDataAssetCollection>
Runtime.createReplayRecorder() method
Create a new ReplayRecorder object that can be used to record a session of game play events
Signature:
createReplayRecorder(timer?: ITimer): Promise<ReplayRecorder>;
Parameters
Parameter | Type | Description |
---|---|---|
timer | ITimer | (Optional) Optionally pass in an ITimer to control the timing of the time events |
Returns:
Promise<ReplayRecorder>
Runtime.createVideoAssetCollection() method
Warning: This API is now obsolete.
Use same method on AssetManager
Create a new VideoAssetCollection that can be used to save multiple videos as a single output asset
Signature:
createVideoAssetCollection(): Promise<VideoAssetCollection>;
Returns:
Promise<VideoAssetCollection>
Runtime.getAnalyticService() method
Get the AnalyticService for BI logging.
Signature:
getAnalyticService(): AnalyticService | undefined;
Returns:
AnalyticService | undefined
Runtime.getAmazonService() method
Get the Amazon service used to connect to the Amazon API
Signature:
getAmazonService(): AmazonService | undefined;
Returns:
AmazonService | undefined
Runtime.getAssetManager() method
Get the AssetManager used to manage input and output assets and submission data
Signature:
getAssetManager(): AssetManager | undefined;
Returns:
AssetManager | undefined
Runtime.getAudioManager() method
Get the AudioManager used to play sound effects and music.
Signature:
getAudioManager(): AudioManager | undefined;
Returns:
AudioManager | undefined
Runtime.getConfigValue() method
Lookup data statically configured for this module
Signature:
getConfigValue(key: string): string | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The lookup identifier for the configuration. |
Returns:
string | undefined
The stored data, of the key.
Runtime.getContextDataService() method
Get data about the context the module is running within.
Signature:
getContextDataService(): ContextDataService | undefined;
Returns:
ContextDataService | undefined
Runtime.getControlManager() method
Get the control manager used to modify aspect of the device.
Signature:
getControlManager(): ControlManager | undefined;
Returns:
ControlManager | undefined
Runtime.getFullScreenRecorder() method
Warning: This API is now obsolete.
use ControlManager.getFullScreenRecorder() instead
Get the full screen recorder to be used to capture the full module experience to a video file
Signature:
getFullScreenRecorder(): FullScreenRecorder | undefined;
Returns:
FullScreenRecorder | undefined
Runtime.getFunctionService() method
Get the function service used to call module cloud functions
Signature:
getFunctionService(): FunctionService | undefined;
Returns:
FunctionService | undefined
Runtime.getInputAsset() method
Warning: This API is now obsolete.
Use AssetManager.getInputAsset() instead
Get an asset that has been passed from the framework into the module, available on startup
Signature:
getInputAsset(name: string): IModuleAsset | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The asset identifier as setup in the module configuration |
Returns:
IModuleAsset | undefined
An asset reference of the configured type
Runtime.getInputManager() method
Get the input manger used to access API features like face and body tracking.
Signature:
getInputManager(): InputManager | undefined;
Returns:
InputManager | undefined
Runtime.getLocalNotificationService() method
Get the local notification service used to schedule local notifications
Signature:
getLocalNotificationService(): LocalNotificationService | undefined;
Returns:
LocalNotificationService | undefined
Runtime.getLayoutManager() method
Get the LayoutManager used to control the display of Oooh rendered components like Camera, and Video.
Signature:
getLayoutManager(): LayoutManager | undefined;
Returns:
LayoutManager | undefined
Runtime.getMediaSourceManager() method
Get the MediaSourceManager for creating camera and video media sources.
Signature:
getMediaSourceManager(): MediaSourceManager | undefined;
Returns:
MediaSourceManager | undefined
Runtime.getNativeUIManager() method
Get the native UI manger for use with native controls like the native record button.
Signature:
getNativeUIManager(): NativeUIManager | undefined;
Returns:
NativeUIManager | undefined
Runtime.getOoohMetadataService() method
Warning: This API is now obsolete.
Use Runtime.getContextDataService() instead
Get the oooh metadata service which can be used to get information about the oooh instance.
Signature:
getOoohMetadataService(): ContextDataService | undefined;
Returns:
ContextDataService | undefined
Runtime.getSystemSettingsService() method
Get the system settings service for getting updates on system settings.
Signature:
getSystemSettingsService(): SystemSettingsService | undefined;
Returns:
SystemSettingsService | undefined
Runtime.getPauseSubject() method
Be notified when module execution is paused
Signature:
getPauseSubject(): Subject<boolean>;
Returns:
Subject<boolean>
Remarks
Subscribe to this to be notified when the app is put in the background or the module is paused. True when paused, false when unpaused.
Immediately after the pause state occurs all JS execution is suspended - as if an alert() dialog was triggered. If your module does any wall clock timing checks they will need to be aware of time spent in the paused state and adjust accordingly. Do not make any async calls in response to entering the pause state as execution will be suspended before they can be executed. Content managed by the platform will handle pause / resume state internally (ie: camera, video playback/recording, audio, etc...)
Runtime.getTwitchService() method
Get the Twitch service used to connect to the Twitch API
Signature:
getTwitchService(): TwitchService | undefined;
Returns:
TwitchService | undefined
Runtime.getUserDataService() method
Get the user profile service used to fetch information about the active user and the creator of the Oooh.
Signature:
getUserDataService(): UserDataService | undefined;
Returns:
UserDataService | undefined
Runtime.getUserPersistentDataService() method
Get the user persistent data service used to fetch custom data stored globally about the module or specific to the instance of the Oooh.
Signature:
getUserPersistentDataService(): UserPersistentDataService | undefined;
Returns:
UserPersistentDataService | undefined
Runtime.level property
The level which this module is loaded as.
Signature:
get level(): number;
Remarks
If your module supports more than one level this value needs to be checked on start to determine which level to load
Runtime.openExternalLink() method
Open an external link to a webpage in the in-app browser
Signature:
openExternalLink(url: string): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
url | string | The URL to the external link to open |
Returns:
Promise<void>
A promise that will resolve when the user returns to the module
Remarks
When this is called, the module will be paused and the user will be taken to the external link.
Runtime.playType property
The play type to show your module in.
Signature:
get playType(): Enum<typeof PlayType>;
Remarks
This should be checked while loading your module to customize appearance and behaviour based on how the module is being consumed.
Different PlayTypes likely have different input assets and expect different output assets.
Runtime.ready() method
Your experience must call this when it is fully loaded and ready to start the user experience.
Signature:
ready(callback?: () => void): void;
Parameters
Parameter | Type | Description |
---|---|---|
callback | () => void | (Optional) Called when the user is ready for the module and the view becomes visible. |
Returns:
void
Remarks
Things should be in a paused state at this time and unpause when the callback is triggered, as that is when your module will first become visible.
Updated 7 months ago