@broadcastingplatforms/player 0.0.0-dev.5a7dff6 → 0.0.0-dev.5c5cff9

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,220 @@
1
+ # @broadcastingplatforms/player
2
+
3
+ Universal video player web component built with Lit. Supports HLS, WebRTC (via nanoStream), and LiveKit.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @broadcastingplatforms/player
9
+ # or
10
+ pnpm add @broadcastingplatforms/player
11
+ ```
12
+
13
+ ## Standalone vs Non-Standalone
14
+
15
+ ### Standalone Bundle
16
+
17
+ Use the standalone bundle when you want a single file with all dependencies (HLS.js, etc.) bundled. Ideal for CDN usage or simple HTML pages.
18
+
19
+ ```html
20
+ <script type="module" src="https://unpkg.com/@broadcastingplatforms/player/dist/bp-player.standalone.mjs"></script>
21
+
22
+ <bp-player
23
+ source='{"sources":[{"type":"video","url":"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"}]}'
24
+ muted
25
+ autoplay
26
+ ></bp-player>
27
+ ```
28
+
29
+ ### Non-Standalone (Bundler)
30
+
31
+ Use the standard import when using a bundler (Vite, webpack, etc.). Dependencies are external and tree-shakeable.
32
+
33
+ ```ts
34
+ import '@broadcastingplatforms/player';
35
+ ```
36
+
37
+ ```html
38
+ <bp-player
39
+ source='{"sources":[{"type":"video","url":"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"}]}'
40
+ muted
41
+ autoplay
42
+ ></bp-player>
43
+ ```
44
+
45
+ ## Basic Usage
46
+
47
+ ### HLS Video (Big Buck Bunny)
48
+
49
+ ```html
50
+ <bp-player
51
+ source='{"sources":[{"type":"video","url":"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"}],"poster":"https://peach.blender.org/wp-content/uploads/bbb-splash.png"}'
52
+ muted
53
+ autoplay
54
+ ></bp-player>
55
+ ```
56
+
57
+ ### BPLive Stream
58
+
59
+ Play a live stream from the BPLive platform:
60
+
61
+ ```html
62
+ <bp-player
63
+ source='{"sources":[{"type":"bplive","streamId":123}]}'
64
+ config='{"bpLive":{"discoveryUrl":"https://api.example.com","authToken":"your-auth-token"}}'
65
+ muted
66
+ autoplay
67
+ ></bp-player>
68
+ ```
69
+
70
+ ### BPLive Clip
71
+
72
+ Play a clip from the BPLive platform:
73
+
74
+ ```html
75
+ <bp-player
76
+ source='{"sources":[{"type":"bplive","clipId":456,"preferredOrientation":"portrait"}]}'
77
+ config='{"bpLive":{"discoveryUrl":"https://api.example.com","authToken":"your-auth-token"}}'
78
+ muted
79
+ autoplay
80
+ ></bp-player>
81
+ ```
82
+
83
+ ### With Default UI
84
+
85
+ ```html
86
+ <bp-default-ui
87
+ source='{"sources":[{"type":"video","url":"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"}]}'
88
+ ></bp-default-ui>
89
+ ```
90
+
91
+ ### Programmatic Control
92
+
93
+ ```ts
94
+ import { BPPlayer, type SourceDescription } from '@broadcastingplatforms/player';
95
+
96
+ const player = document.querySelector('bp-player') as BPPlayer;
97
+
98
+ // Set source via property (object)
99
+ player.source = {
100
+ sources: [{ type: 'video', url: 'https://example.com/stream.m3u8' }],
101
+ poster: 'https://example.com/poster.jpg'
102
+ };
103
+
104
+ player.addEventListener('ready', (e) => {
105
+ const core = e.detail; // PlayerCore instance
106
+
107
+ core.play();
108
+ core.pause();
109
+ core.seek(30); // seek to 30 seconds
110
+ core.setVolume(0.5);
111
+ core.setMuted(true);
112
+
113
+ // Access current state
114
+ console.log(core.state.currentTime);
115
+ console.log(core.state.duration);
116
+ console.log(core.state.paused);
117
+ });
118
+ ```
119
+
120
+ ## Attributes
121
+
122
+ Attributes can be set as JSON strings or as JavaScript properties.
123
+
124
+ | Attribute | Type | Description |
125
+ |-----------|------|-------------|
126
+ | `source` | `SourceDescription` (JSON) | Source description with `sources` array and optional `poster` |
127
+ | `config` | `ProviderConfig` (JSON) | Provider configuration (HLS, NanoPlayer, LiveKit, BPLive) |
128
+ | `autoplay` | `boolean` | Auto-start playback |
129
+ | `muted` | `boolean` | Start muted |
130
+ | `loop` | `boolean` | Loop playback |
131
+
132
+ ### SourceDescription
133
+
134
+ ```ts
135
+ interface SourceDescription {
136
+ sources: PlayerSource[];
137
+ poster?: string;
138
+ }
139
+ ```
140
+
141
+ ### PlayerSource Types
142
+
143
+ ```ts
144
+ // Standard video/HLS source
145
+ interface VideoSource {
146
+ type: 'video';
147
+ url: string;
148
+ }
149
+
150
+ // BPLive stream source
151
+ interface BPLiveStreamSource {
152
+ type: 'bplive';
153
+ streamId: number;
154
+ }
155
+
156
+ // BPLive clip source
157
+ interface BPLiveClipSource {
158
+ type: 'bplive';
159
+ clipId: number;
160
+ preferredOrientation?: 'landscape' | 'portrait'; // defaults to 'landscape'
161
+ }
162
+ ```
163
+
164
+ ### ProviderConfig
165
+
166
+ ```ts
167
+ interface ProviderConfig {
168
+ bpLive?: BPLiveConfig;
169
+ // ... other provider configs
170
+ }
171
+
172
+ interface BPLiveConfig {
173
+ discoveryUrl: string; // Base URL of the BPLive API (required)
174
+ authToken?: string; // Bearer token for authenticated API requests
175
+ }
176
+ ```
177
+
178
+ ### Analytics
179
+
180
+ Connect analytics via the `ready` event using `@broadcastingplatforms/web-connectors`:
181
+
182
+ ```html
183
+ <bp-player
184
+ id="player"
185
+ source='{"sources":[{"type":"video","url":"..."}]}'
186
+ ></bp-player>
187
+
188
+ <script type="module">
189
+ import { createMuxConnector } from '@broadcastingplatforms/web-connectors/mux';
190
+
191
+ document.getElementById('player').addEventListener('ready', (e) => {
192
+ // Auto-destroys when player is destroyed
193
+ createMuxConnector(e.detail, {
194
+ envKey: 'your-mux-env-key',
195
+ data: { video_title: 'My Video' }
196
+ });
197
+ });
198
+ </script>
199
+ ```
200
+
201
+ ## Events
202
+
203
+ | Event | Detail | Description |
204
+ |-------|--------|-------------|
205
+ | `ready` | `PlayerCore` | Fired when player is ready |
206
+ | `play` | - | Playback started |
207
+ | `pause` | - | Playback paused |
208
+ | `ended` | - | Playback ended |
209
+ | `timeupdate` | - | Current time updated |
210
+ | `error` | - | Playback error occurred |
211
+
212
+ ## Custom Video Elements
213
+
214
+ For advanced use cases, you can use the custom video elements directly:
215
+
216
+ ```ts
217
+ import { HlsVideoElement, NanoVideoElement, LiveKitVideoElement } from '@broadcastingplatforms/player/elements';
218
+ ```
219
+
220
+ These are [media-chrome](https://www.media-chrome.org/) compatible custom elements.