@broadcastingplatforms/player 0.0.0-dev.8eb2bc0 → 0.0.0-dev.c57124a

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.
@@ -3,6 +3,7 @@ import { type PlayerCore } from '../core/player-core';
3
3
  import type { PlayerState } from '../core/state';
4
4
  import type { ProviderType, ProviderConfig, SourceDescription } from '../providers/contract';
5
5
  import type { BPLiveService } from '../bplive/service';
6
+ import { VideoRenditionList } from './video-rendition-list';
6
7
  export type BPPlayerReadyEvent = CustomEvent<PlayerCore>;
7
8
  declare global {
8
9
  interface HTMLElementTagNameMap {
@@ -12,28 +13,6 @@ declare global {
12
13
  'ready': BPPlayerReadyEvent;
13
14
  }
14
15
  }
15
- interface VideoRendition {
16
- id: string;
17
- width: number;
18
- height: number;
19
- bitrate: number;
20
- selected: boolean;
21
- }
22
- declare class VideoRenditionList extends EventTarget {
23
- [index: number]: VideoRendition;
24
- private _player;
25
- private _renditions;
26
- private _cleanup;
27
- constructor(player: BPPlayer);
28
- get length(): number;
29
- [Symbol.iterator](): Iterator<VideoRendition>;
30
- get selectedIndex(): number;
31
- set selectedIndex(index: number);
32
- private _updateSelection;
33
- _syncFromPlayer(): void;
34
- _setupListeners(): void;
35
- _destroy(): void;
36
- }
37
16
  export declare class BPPlayer extends LitElement {
38
17
  protected createRenderRoot(): HTMLElement | DocumentFragment;
39
18
  connectedCallback(): void;
@@ -46,12 +25,13 @@ export declare class BPPlayer extends LitElement {
46
25
  config?: ProviderConfig;
47
26
  debug: boolean;
48
27
  private _playerCore;
49
- private _ready;
50
28
  private containerRef;
51
29
  private providerContainer;
52
30
  private eventCleanup;
53
31
  private stateReceivers;
54
32
  private _mutationObserver;
33
+ private _videoRenditions;
34
+ private _hasDispatchedReady;
55
35
  get player(): PlayerCore | null;
56
36
  get playerState(): PlayerState | null;
57
37
  get bpLive(): BPLiveService | null;
@@ -76,20 +56,24 @@ export declare class BPPlayer extends LitElement {
76
56
  get videoHeight(): number;
77
57
  get videoElement(): HTMLVideoElement | null;
78
58
  get providerType(): ProviderType | null;
79
- get videoRenditions(): VideoRenditionList;
80
- private _videoRenditions;
59
+ get videoRenditions(): VideoRenditionList | null;
81
60
  disconnectedCallback(): void;
82
61
  protected firstUpdated(_changedProperties: PropertyValues): void;
83
62
  protected updated(changedProperties: PropertyValues): void;
84
- private getPlayableSource;
63
+ /**
64
+ * Initialize player core once. Called in firstUpdated.
65
+ */
66
+ private initPlayerCore;
67
+ /**
68
+ * Load source into player core. Player core handles provider switching internally.
69
+ */
70
+ private loadSource;
85
71
  private handleMutation;
86
72
  private registerStateReceiver;
87
73
  private unregisterStateReceiver;
88
74
  private propagateStateToAllReceivers;
89
75
  private setupEventForwarding;
90
76
  private updateStateAttributes;
91
- private initPlayer;
92
- private loadPlayableSource;
93
77
  private destroyPlayer;
94
78
  /** Update video dimension CSS variables */
95
79
  updateVideoDimensions(width: number, height: number): void;
@@ -99,5 +83,4 @@ export declare class BPPlayer extends LitElement {
99
83
  private getContainerStyle;
100
84
  protected render(): import("lit").TemplateResult<1>;
101
85
  }
102
- export {};
103
86
  //# sourceMappingURL=bp-player.d.ts.map
@@ -2,4 +2,5 @@ export { BPPlayer, type BPPlayerReadyEvent } from './bp-player';
2
2
  export { BPDefaultUI, type BPDefaultUIReadyEvent } from './bp-default-ui';
3
3
  export { BPErrorDisplay } from './bp-error-display';
4
4
  export { BPOverlay, type OverlayType } from './bp-overlay';
5
+ export { VideoRenditionList, type VideoRendition, type VideoRenditionHost } from './video-rendition-list';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { PlayerCore } from '../core/player-core';
2
+ /**
3
+ * Represents a single video rendition/quality level.
4
+ * Compatible with media-chrome's VideoRendition interface.
5
+ */
6
+ export interface VideoRendition {
7
+ id: string;
8
+ width: number;
9
+ height: number;
10
+ bitrate: number;
11
+ selected: boolean;
12
+ }
13
+ /**
14
+ * Interface for the player host that provides access to PlayerCore.
15
+ */
16
+ export interface VideoRenditionHost {
17
+ readonly player: PlayerCore | null;
18
+ }
19
+ /**
20
+ * VideoRenditionList provides media-chrome compatibility for quality selection.
21
+ * It exposes video quality levels as an iterable list with selection support.
22
+ */
23
+ export declare class VideoRenditionList extends EventTarget {
24
+ [index: number]: VideoRendition;
25
+ private _host;
26
+ private _renditions;
27
+ private _cleanup;
28
+ constructor(host: VideoRenditionHost);
29
+ get length(): number;
30
+ [Symbol.iterator](): Iterator<VideoRendition>;
31
+ get selectedIndex(): number;
32
+ set selectedIndex(index: number);
33
+ private _updateSelection;
34
+ _syncFromPlayer(): void;
35
+ _setupListeners(): void;
36
+ _destroy(): void;
37
+ }
38
+ //# sourceMappingURL=video-rendition-list.d.ts.map
@@ -1,5 +1,5 @@
1
1
  export { createPlayerCore, PlayerCoreImpl } from './player-core';
2
- export type { PlayerCore, PlayerCoreEventMap, PlayerCoreEventType } from './player-core';
2
+ export type { PlayerCore, PlayerCoreEventMap, PlayerCoreEventType, SourceLoadResult } from './player-core';
3
3
  export { createInitialState, classifyNanoPlayerError, classifyLiveKitError, NANOPLAYER_NO_REPLAY_CODES } from './state';
4
4
  export type { PlayerState, QualityLevel, PresentationMode, ConnectionState, StreamType, ProviderType, PlayerError, ErrorCategory, } from './state';
5
5
  export { StateReceiverMixin, StateReceiverProps, isStateReceiverElement, forEachStateReceiverElement, propagateStateToReceiver, removeStateFromReceiver, } from './state-receiver';
@@ -1,5 +1,5 @@
1
1
  import type { PlayerState, QualityLevel, PresentationMode, ConnectionState, StreamType, PlayerError } from './state';
2
- import type { PlayerSource, ProviderConfig } from '../providers/contract';
2
+ import type { ProviderType, PlayerSource, ProviderConfig } from '../providers/contract';
3
3
  import { BPLiveService } from '../bplive/service';
4
4
  export interface PlayerCoreEventMap {
5
5
  play: void;
@@ -17,6 +17,7 @@ export interface PlayerCoreEventMap {
17
17
  currentTime: number;
18
18
  duration: number;
19
19
  };
20
+ emptied: void;
20
21
  loadstart: void;
21
22
  loadedmetadata: {
22
23
  duration: number;
@@ -86,17 +87,35 @@ type EventListener<T> = (event: T) => void;
86
87
  export type CustomVideoElement = HTMLVideoElement & {
87
88
  nativeEl: HTMLVideoElement;
88
89
  };
90
+ /**
91
+ * Result returned when a source is loaded, containing metadata from the source.
92
+ */
93
+ export interface SourceLoadResult {
94
+ poster?: string;
95
+ videoWidth?: number;
96
+ videoHeight?: number;
97
+ }
89
98
  export interface PlayerCore {
90
99
  readonly state: PlayerState;
91
100
  readonly videoElement: HTMLVideoElement | null;
92
101
  readonly bpLive: BPLiveService | null;
102
+ /** Whether the player is ready (attached and can accept sources) */
103
+ readonly ready: boolean;
104
+ /** Current provider type based on loaded source */
105
+ readonly providerType: ProviderType | null;
93
106
  addEventListener<K extends PlayerCoreEventType>(type: K | K[], listener: EventListener<PlayerCoreEventMap[K]>): void;
94
107
  removeEventListener<K extends PlayerCoreEventType>(type: K | K[], listener: EventListener<PlayerCoreEventMap[K]>): void;
95
- loadSource(source: string | PlayerSource, container: HTMLElement, config?: ProviderConfig): Promise<{
96
- poster?: string;
97
- videoWidth?: number;
98
- videoHeight?: number;
99
- } | void>;
108
+ /**
109
+ * Attach the player to a container element. Call once during initialization.
110
+ * After attaching, you can set sources via the source property or loadSource().
111
+ */
112
+ attach(container: HTMLElement, config?: ProviderConfig): void;
113
+ /**
114
+ * Load a source. Handles provider switching automatically.
115
+ * If source type changes (e.g., video -> nano), the player will
116
+ * destroy the old element and create a new one.
117
+ */
118
+ loadSource(source: string | PlayerSource, container?: HTMLElement, config?: ProviderConfig): Promise<SourceLoadResult | void>;
100
119
  unloadSource(): void;
101
120
  play(): Promise<void>;
102
121
  pause(): void;
@@ -115,23 +134,32 @@ export declare class PlayerCoreImpl implements PlayerCore {
115
134
  private _state;
116
135
  private _mediaElement;
117
136
  private _container;
137
+ private _config;
118
138
  private _listeners;
119
139
  private _eventCleanup;
120
140
  private _destroyed;
121
141
  private _bpLive;
142
+ private _currentProviderType;
143
+ private _ready;
122
144
  constructor();
123
145
  get state(): PlayerState;
124
146
  get videoElement(): HTMLVideoElement | null;
125
147
  get bpLive(): BPLiveService | null;
148
+ get ready(): boolean;
149
+ get providerType(): ProviderType | null;
126
150
  addEventListener<K extends PlayerCoreEventType>(type: K | K[], listener: EventListener<PlayerCoreEventMap[K]>): void;
127
151
  removeEventListener<K extends PlayerCoreEventType>(type: K | K[], listener: EventListener<PlayerCoreEventMap[K]>): void;
128
152
  private dispatch;
129
153
  private updateState;
130
- loadSource(source: string | PlayerSource, container: HTMLElement, config?: ProviderConfig): Promise<{
131
- poster?: string;
132
- videoWidth?: number;
133
- videoHeight?: number;
134
- } | void>;
154
+ /**
155
+ * Attach the player to a container. Call once during initialization.
156
+ */
157
+ attach(container: HTMLElement, config?: ProviderConfig): void;
158
+ loadSource(source: string | PlayerSource, container?: HTMLElement, config?: ProviderConfig): Promise<SourceLoadResult | void>;
159
+ /**
160
+ * Destroy the current media element and clean up listeners.
161
+ */
162
+ private destroyMediaElement;
135
163
  private createMediaElement;
136
164
  private attachMediaElementListeners;
137
165
  private handleMediaEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broadcastingplatforms/player",
3
- "version": "0.0.0-dev.8eb2bc0",
3
+ "version": "0.0.0-dev.c57124a",
4
4
  "description": "Universal video player web component built with Lit",
5
5
  "type": "module",
6
6
  "main": "dist/bp-player.js",
@@ -54,7 +54,7 @@
54
54
  "esbuild": "^0.24.0",
55
55
  "typescript": "^5.7.2",
56
56
  "vite": "^6.0.5",
57
- "@broadcastingplatforms/web-connectors": "0.0.0-dev.8eb2bc0"
57
+ "@broadcastingplatforms/web-connectors": "0.0.0-dev.c57124a"
58
58
  },
59
59
  "license": "UNLICENSED",
60
60
  "publishConfig": {