@broadcastingplatforms/player 0.0.0-dev.5a7dff6 → 0.0.0-dev.69b5249
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 +157 -0
- package/dist/bp-player.js +141 -138
- package/dist/bp-player.mjs +132 -129
- package/dist/bp-player.standalone.mjs +147 -144
- package/dist/bplive/service.d.ts +4 -2
- package/dist/components/bp-default-ui.d.ts +8 -3
- package/dist/components/bp-player.d.ts +7 -5
- package/dist/core/player-core.d.ts +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/providers/contract.d.ts +9 -0
- package/dist/util/attribute.d.ts +0 -2
- package/package.json +3 -2
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.
|