@broadcastingplatforms/player 0.0.0-dev.3802fed → 0.0.0-dev.7888976

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.
Files changed (35) hide show
  1. package/README.md +157 -0
  2. package/dist/bp-player.js +126 -126
  3. package/dist/bp-player.mjs +125 -125
  4. package/dist/bp-player.standalone.mjs +140 -140
  5. package/dist/components/bp-default-ui.d.ts +2 -2
  6. package/dist/components/bp-player.d.ts +3 -3
  7. package/dist/index.d.ts +1 -1
  8. package/dist/providers/contract.d.ts +9 -0
  9. package/dist/util/attribute.d.ts +0 -2
  10. package/package.json +5 -3
  11. package/dist/bp-player.js.map +0 -7
  12. package/dist/bp-player.mjs.map +0 -7
  13. package/dist/bp-player.standalone.mjs.map +0 -7
  14. package/dist/bplive/index.d.ts.map +0 -1
  15. package/dist/bplive/service.d.ts.map +0 -1
  16. package/dist/bplive/types.d.ts.map +0 -1
  17. package/dist/components/bp-default-ui.d.ts.map +0 -1
  18. package/dist/components/bp-error-display.d.ts.map +0 -1
  19. package/dist/components/bp-overlay.d.ts.map +0 -1
  20. package/dist/components/bp-player.d.ts.map +0 -1
  21. package/dist/components/index.d.ts.map +0 -1
  22. package/dist/core/index.d.ts.map +0 -1
  23. package/dist/core/player-core.d.ts.map +0 -1
  24. package/dist/core/state-receiver.d.ts.map +0 -1
  25. package/dist/core/state.d.ts.map +0 -1
  26. package/dist/elements/hls-video.d.ts.map +0 -1
  27. package/dist/elements/index.d.ts.map +0 -1
  28. package/dist/elements/livekit-video.d.ts.map +0 -1
  29. package/dist/elements/nano-video.d.ts.map +0 -1
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/providers/contract.d.ts.map +0 -1
  32. package/dist/providers/index.d.ts.map +0 -1
  33. package/dist/styles/index.d.ts.map +0 -1
  34. package/dist/util/attribute.d.ts.map +0 -1
  35. package/dist/util/index.d.ts.map +0 -1
package/README.md ADDED
@@ -0,0 +1,157 @@
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
+ ### With Default UI
58
+
59
+ ```html
60
+ <bp-default-ui
61
+ source='{"sources":[{"type":"video","url":"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"}]}'
62
+ ></bp-default-ui>
63
+ ```
64
+
65
+ ### Programmatic Control
66
+
67
+ ```ts
68
+ import { BPPlayer, type SourceDescription } from '@broadcastingplatforms/player';
69
+
70
+ const player = document.querySelector('bp-player') as BPPlayer;
71
+
72
+ // Set source via property (object)
73
+ player.source = {
74
+ sources: [{ type: 'video', url: 'https://example.com/stream.m3u8' }],
75
+ poster: 'https://example.com/poster.jpg'
76
+ };
77
+
78
+ player.addEventListener('ready', (e) => {
79
+ const core = e.detail; // PlayerCore instance
80
+
81
+ core.play();
82
+ core.pause();
83
+ core.seek(30); // seek to 30 seconds
84
+ core.setVolume(0.5);
85
+ core.setMuted(true);
86
+
87
+ // Access current state
88
+ console.log(core.state.currentTime);
89
+ console.log(core.state.duration);
90
+ console.log(core.state.paused);
91
+ });
92
+ ```
93
+
94
+ ## Attributes
95
+
96
+ Attributes can be set as JSON strings or as JavaScript properties.
97
+
98
+ | Attribute | Type | Description |
99
+ |-----------|------|-------------|
100
+ | `source` | `SourceDescription` (JSON) | Source description with `sources` array and optional `poster` |
101
+ | `config` | `ProviderConfig` (JSON) | Provider configuration (HLS, NanoPlayer, LiveKit, BPLive) |
102
+ | `autoplay` | `boolean` | Auto-start playback |
103
+ | `muted` | `boolean` | Start muted |
104
+ | `loop` | `boolean` | Loop playback |
105
+
106
+ ### SourceDescription
107
+
108
+ ```ts
109
+ interface SourceDescription {
110
+ sources: PlayerSource[];
111
+ poster?: string;
112
+ }
113
+ ```
114
+
115
+ ### Analytics
116
+
117
+ Connect analytics via the `ready` event using `@broadcastingplatforms/web-connectors`:
118
+
119
+ ```html
120
+ <bp-player
121
+ id="player"
122
+ source='{"sources":[{"type":"video","url":"..."}]}'
123
+ ></bp-player>
124
+
125
+ <script type="module">
126
+ import { createMuxConnector } from '@broadcastingplatforms/web-connectors/mux';
127
+
128
+ document.getElementById('player').addEventListener('ready', (e) => {
129
+ // Auto-destroys when player is destroyed
130
+ createMuxConnector(e.detail, {
131
+ envKey: 'your-mux-env-key',
132
+ data: { video_title: 'My Video' }
133
+ });
134
+ });
135
+ </script>
136
+ ```
137
+
138
+ ## Events
139
+
140
+ | Event | Detail | Description |
141
+ |-------|--------|-------------|
142
+ | `ready` | `PlayerCore` | Fired when player is ready |
143
+ | `play` | - | Playback started |
144
+ | `pause` | - | Playback paused |
145
+ | `ended` | - | Playback ended |
146
+ | `timeupdate` | - | Current time updated |
147
+ | `error` | - | Playback error occurred |
148
+
149
+ ## Custom Video Elements
150
+
151
+ For advanced use cases, you can use the custom video elements directly:
152
+
153
+ ```ts
154
+ import { HlsVideoElement, NanoVideoElement, LiveKitVideoElement } from '@broadcastingplatforms/player/elements';
155
+ ```
156
+
157
+ These are [media-chrome](https://www.media-chrome.org/) compatible custom elements.