Media Recorder Events
Description
This Media Recorder allows you to capure screenshots and record video of your Studio project at runtime.
Media Recorder events are emitted on the world.events.globalId.
Events
RECORDER_SCREENSHOT_READY
Emitted when screenshot is ready.
Properties
| Property | Type | Description |
|---|---|---|
| blob | Blob | The JPEG image blob of the screenshot |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_SCREENSHOT_READY, (event) => {
console.log('Screenshot blob: ', event.data.blob)
})
RECORDER_VIDEO_STARTED
Emitted when recording has started.
Properties
None.
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_VIDEO_STARTED, () => {
console.log('Recording started')
})
RECORDER_VIDEO_STOPPED
Emitted when recording has stopped.
Properties
None.
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_VIDEO_STARTED, () => {
console.log('Recording stopped')
})
RECORDER_VIDEO_ERROR
Emitted when there is an error.
Properties
| Property | Type | Description |
|---|---|---|
| message | string | The error message |
| name | string | The error name |
| stack | string | The error stack trace |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_VIDEO_ERROR, (event) => {
console.log('Recorder error: ', event.data.message)
})
RECORDER_VIDEO_READY
Emitted when recording has completed and video is ready.
Properties
| Property | Type | Description |
|---|---|---|
| videoBlob | Blob | The recorded video blob |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_VIDEO_READY, (event) => {
console.log('Video ready: ', event.data.videoBlob)
})
RECORDER_PREVIEW_READY
Emitted when a previewable, but not sharing-optimized, video is ready (Android/Desktop only).
Properties
| Property | Type | Description |
|---|---|---|
| videoBlob | Blob | The preview video blob |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_PREVIEW_READY, (event) => {
console.log('Preview ready: ', event.data.videoBlob)
})
RECORDER_FINALIZE_PROGRESS
Emitted when the media recorder is making progress in the final export (Android/Desktop only).
Properties
| Property | Type | Description |
|---|---|---|
| progress | number | Finalization progress (0 to 1) |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_FINALIZE_PROGRESS, (event) => {
console.log('Finalize progress: ', event.data.progress * 100)
})
RECORDER_PROCESS_FRAME
Properties
| Property | Type | Description |
|---|---|---|
| frame | ImageData | The processed video frame |
| timestamp | number | The timestamp of the frame (ms) |
Example
- .listen
- .onEvent
- .addEventListener
defineState('initial-state').initial().listen(world.events.globalId, ecs.events.RECORDER_PROCESS_FRAME, (event) => {
console.log('Process frame: ', event.data.timestamp, event.data.frame)
})