The root entry exposes three class-based APIs for media: Camera, Mic, and
Screen. Each follows the same pattern: construct an instance and assign a
callback setter. The metatell host invokes your callback when the corresponding
event occurs.
import { Mic } from "@urth/metatell-sdk";
const mic = new Mic();
// fired when a captured audio segment is ready
mic.onSpeechEnd = (file) => {
console.log("audio file", file); // File
};
// fired when the active audio device changes
mic.onChangeDevice = (info) => {
console.log(info.deviceId, info.deviceName, info.status);
};
DeviceData:
interface DeviceData {
deviceId: string;
deviceName: string;
status: "mute" | "unmute";
}
import { Camera } from "@urth/metatell-sdk";
const camera = new Camera();
// fired when the camera orientation changes
camera.onChangeCamera = (transform) => {
console.log(transform.position, transform.rotation, transform.quaternion);
};
The callback receives a TransformData (see Avatar for the
shape).
import { Screen } from "@urth/metatell-sdk";
const screen = new Screen();
// fired when screen sharing starts (MediaStream) or stops (null)
screen.onScreenShare = (media) => {
if (media) {
videoEl.srcObject = media; // MediaStream
} else {
videoEl.srcObject = null;
}
};
window.MetatellPlugin to be present, i.e. the plugin
must run inside the metatell host.