Realtime Media Overview

Isometrik provides powerful realtime media capabilities for audio, video, and screen sharing. This section covers the fundamentals of working with media tracks.

Media Tracks

Media tracks represent audio or video streams. There are two types:

Local Tracks

Local tracks are created from your device's camera and microphone. You publish these tracks to share them with other participants.

Remote Tracks

Remote tracks are received from other participants. You subscribe to these tracks to receive their audio and video.

Publishing Tracks

To share your camera and microphone:

// Get user media
const tracks = await room.localParticipant.publishTracks({
  audio: true,
  video: true
});

// Tracks are automatically published to the room
console.log('Published tracks:', tracks);

Subscribing to Tracks

To receive tracks from other participants:

// Listen for new tracks
room.on('trackSubscribed', (track, participant) => {
  if (track.kind === 'video') {
    const videoElement = document.createElement('video');
    track.attach(videoElement);
    document.body.appendChild(videoElement);
  } else if (track.kind === 'audio') {
    const audioElement = document.createElement('audio');
    track.attach(audioElement);
    audioElement.play();
  }
});

Track Controls

You can control tracks programmatically:

// Mute/unmute audio
await audioTrack.setMuted(true);

// Enable/disable video
await videoTrack.setEnabled(false);

// Stop a track
await track.stop();

// Replace camera
const newVideoTrack = await createLocalVideoTrack({
  facingMode: 'environment' // Use back camera
});
await room.localParticipant.replaceTrack(oldTrack, newVideoTrack);

Screen Sharing

Share your screen with other participants:

// Start screen sharing
const screenTrack = await createLocalScreenTracks({
  video: true,
  audio: true
});

await room.localParticipant.publishTracks(screenTrack);

// Stop screen sharing
screenTrack.forEach(track => track.stop());

Media Quality

Control video quality and bitrate:

// Set video quality
await videoTrack.setVideoQuality({
  resolution: { width: 1280, height: 720 },
  bitrate: 2000000 // 2 Mbps
});

// Adaptive quality (automatically adjusts based on network)
await videoTrack.setAdaptiveQuality(true);

Next Steps