@daydreamlive/browser 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @daydreamlive/browser
2
+
3
+ WebRTC client for Daydream. Framework-agnostic, zero dependencies.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @daydreamlive/browser
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Broadcast
14
+
15
+ ```typescript
16
+ import { createBroadcast } from "@daydreamlive/browser";
17
+
18
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
19
+
20
+ const broadcast = createBroadcast({
21
+ whipUrl: "https://...", // from your backend via @daydreamlive/sdk
22
+ stream,
23
+ });
24
+
25
+ broadcast.on("stateChange", (state) => {
26
+ console.log(state); // 'connecting' | 'live' | 'reconnecting' | 'ended' | 'error'
27
+ });
28
+
29
+ await broadcast.connect();
30
+
31
+ // WHEP URL is available after connection
32
+ console.log(broadcast.whepUrl);
33
+
34
+ // Stop
35
+ await broadcast.stop();
36
+ ```
37
+
38
+ ### Player
39
+
40
+ ```typescript
41
+ import { createPlayer } from "@daydreamlive/browser";
42
+
43
+ const player = createPlayer(whepUrl);
44
+
45
+ player.on("stateChange", (state) => {
46
+ console.log(state); // 'connecting' | 'playing' | 'buffering' | 'ended' | 'error'
47
+ });
48
+
49
+ await player.connect();
50
+ player.attachTo(document.querySelector("video"));
51
+
52
+ // Stop
53
+ player.stop();
54
+ ```
55
+
56
+ ## API
57
+
58
+ ### `createBroadcast(options)`
59
+
60
+ | Option | Type | Description |
61
+ | ----------- | ----------------- | --------------------------- |
62
+ | `whipUrl` | `string` | WHIP endpoint URL |
63
+ | `stream` | `MediaStream` | Media stream to broadcast |
64
+ | `reconnect` | `ReconnectConfig` | Reconnection settings |
65
+ | `video` | `VideoConfig` | Bitrate, framerate settings |
66
+
67
+ ### `createPlayer(whepUrl, options?)`
68
+
69
+ | Option | Type | Description |
70
+ | ----------- | ----------------- | --------------------- |
71
+ | `reconnect` | `ReconnectConfig` | Reconnection settings |
72
+
73
+ ## License
74
+
75
+ MIT