Docs / Web / ZEGOCLOUD
ZEGOCLOUD on the Web
Publish a beautified camera in ZEGOCLOUD Express Web by passing Facevity's processed track as a custom video source.
Demo app: facevity-web-demo on GitHub
ZEGOCLOUD Express Web can publish a stream built from your own MediaStream. Wrap Facevity’s processed track in one and create the ZEGO stream from it.
1. Requirements
@facevity/webset up as in the quick start- ZEGOCLOUD Express Web SDK (
zego-express-engine-webrtc) - A licence that lists the page’s domain
2. Create and publish the stream
import { ZegoExpressEngine } from 'zego-express-engine-webrtc';
import { Facevity, BeautyParams } from '@facevity/web';
const fv = await Facevity.initialize({ licenseToken, assetsBaseUrl: '/facevity/' });
fv.setParams(BeautyParams.NATURAL);
const zg = new ZegoExpressEngine(appID, server);
await zg.loginRoom(roomID, token, { userID, userName });
const camera = (await navigator.mediaDevices.getUserMedia({ video: true })).getVideoTracks()[0];
const source = new MediaStream([fv.createProcessedTrack(camera)]);
const stream = await zg.createZegoStream({ custom: { video: { source } } }); // 2.x: zg.createStream({ custom: { source } })
stream.playVideo(document.getElementById('local-player')!);
zg.startPublishingStream(streamID, stream);
3. Tear down
zg.stopPublishingStream(streamID);
zg.destroyStream(stream);
source.getTracks().forEach((t) => t.stop());
camera.stop();
fv.release();
await zg.logoutRoom(roomID);
Notes
- To add audio, put the microphone track into the same
MediaStreamor use ZEGO’scustom.audiosource. - Beauty settings apply live to the published stream.
Next: LiveKit on the Web · all platforms
Need help with an integration? Contact the Facevity team. We answer integration questions during trials.