Guides
Watch a broadcast and render it
Play a broadcast from its ticket in a window, a browser or your own program.
In short
irl watch <TICKET>
use iroh_live::media::{PlayerConfig, SubscriptionExt};
use iroh_live::{BroadcastTicket, Node};
async fn run(node: &Node, ticket: &BroadcastTicket) -> Result<(), Box<dyn std::error::Error>> {
let subscription = node.subscribe_ticket(ticket).await?;
let player = subscription.remote_broadcast().play(PlayerConfig::default())?;
let mut frames = player.video_frames();
while let Some(frame) = frames.next().await {
println!("frame {}", frame.size());
}
Ok(())
}
The Rust quickstart has the complete program.
Watch from a ticket
irl watch takes the ticket the publisher prints, and --scan reads it
from a QR code:
irl watch <TICKET>
irl watch --scan
In Rust, a ticket parses into a BroadcastTicket, and
Node::subscribe_ticket connects to the publisher.
Watch in a window
irl watch opens a window with a stats overlay, and --fullscreen fills
the screen. In Rust, Player::video_frames() returns the decoded frames,
and Draw video frames draws them with wgpu or
egui.
Watch in a browser
A browser watches through a media relay. To try it locally, run one and
open http://localhost:4443/?name=<TICKET>:
cargo run -p iroh-live-relay -- --open-pulls
Watch in a browser covers a media relay that others can reach.
Play the audio
irl watch plays the audio. --no-video plays only the audio, and
--audio-output picks the speaker:
irl watch --no-video <TICKET>
A Rust player plays audio only when its config asks for it:
use iroh_live::{Subscription, media::{AudioMode, Player, PlayerConfig, SubscriptionExt, audio::playback::Engine}};
async fn run(subscription: &Subscription) -> Result<Player, Box<dyn std::error::Error>> {
// One engine per speaker mixes every player on it.
let speaker = Engine::open(Default::default()).await?;
let config = PlayerConfig::default().with_audio(AudioMode::Play(speaker));
let player = subscription.remote_broadcast().play(config)?;
Ok(player)
}
AudioMode::Decode decodes without a speaker, and
AudioMode::play_or_decode falls back to it when no speaker opened.
Choose the latency
The player holds each frame briefly to absorb jitter. --latency realtime
suits calls, balanced is the default, and smooth suits Wi-Fi or mobile
links.
irl watch <TICKET> --latency smooth
In Rust, PlayerConfig::with_latency sets it, as
Tune quality and latency shows.
Going further
- Draw video frames with wgpu or egui.
- Tune quality and latency: pin a rendition, pick the decoder, read the stats.
- Record a broadcast.
- Tutorial: a video call app.
- Subscribing internals.