Skip to main content

Overview

Playing WebRTC streams allows you to receive live video and audio from Ant Media Server with ultra-low latency. The player automatically handles adaptive bitrate streaming, network fluctuations, and quality adjustments.

Quick Start

Basic Player Example

HTML Setup

Configuration Options

SDP Constraints for Playback

Audio-Only Playback

Video-Only Playback

Player Mode Flag

Callbacks

Playback Callback Events

Error Handling

Adaptive Bitrate Playback

Automatic Quality Selection

The server automatically selects the best quality based on network conditions:

Force Specific Quality

Override automatic selection to force a specific resolution:

Get Available Resolutions

Multi-Track Playback

Playing Multiple Tracks

Playing with Subtracks

Advanced Features

Playing with Token Authentication

Playing with Subscriber Information

Enable Data Channel

Server-Side API

IWebRTCClient Interface

The server-side client interface handles media transmission:

Quality Control

The server adapts streaming quality automatically:

Player Statistics

Real-Time Statistics

Best Practices

1. Handle Stream Availability

2. Auto-Reconnect on Failure

3. Clean Up Resources

4. Handle Mobile Browsers

Troubleshooting

Common Issues

Issue: Video not playing
  • Check if stream exists and is live
  • Verify remoteVideoId matches video element ID
  • Ensure autoplay is enabled on video element
  • Check browser autoplay policies (may require muted or user interaction)
Issue: High latency
  • Check network conditions and bandwidth
  • Verify WebRTC ports are not blocked
  • Consider using TURN server if behind restrictive firewall
  • Check server load and available resources
Issue: Playback keeps buffering
  • Network bandwidth insufficient for stream quality
  • Let adaptive bitrate algorithm adjust quality
  • Check for packet loss in statistics

Next Steps

Publishing Streams

Learn how to publish WebRTC streams

Peer-to-Peer

Build P2P applications with WebRTC