@vplayer/core 0.1.2 → 0.1.4

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/dist/index.d.ts CHANGED
@@ -19,5 +19,5 @@ export { defaultPlayerLabels, defaultPlayerIcons } from './defaults';
19
19
  export { BaseMediaEngine, NativeVideoEngine, HlsMediaEngine, DashMediaEngine } from './media-engine';
20
20
  export type { MediaEngine, MediaEngineDimensions, MediaEngineError, MediaEngineEvent, MediaEngineEventHandler, HlsMediaEngineOptions, DashMediaEngineOptions, } from './media-engine';
21
21
  export { createMediaStore, getInitialMediaState, selectMedia, selectAudio, selectPreferences, selectUI, selectPlugins, selectThumbnails, selectError, } from './state/slices';
22
- export type { PlayerOptions, MediaState, MediaRemote, PlayerLabels, PlayerIcons, SvgIcon, PlayerInstance, PlayerSystems, PlayerError, PlaybackStatus, } from './types';
22
+ export type { PlayerOptions, TransformThumbnailVTT, MediaState, MediaRemote, PlayerLabels, PlayerIcons, SvgIcon, PlayerInstance, PlayerSystems, PlayerError, PlaybackStatus, } from './types';
23
23
  export type { ControlRegistration, SettingRegistration, LayerRegistration, ContextMenuItem, ContextMenuRegistration, PlayerPlugin, PluginAPI, RemoteRef, PlayerContextRef, FlipState, AspectRatioState, SettingItem, } from './plugin-api';
package/dist/index.js CHANGED
@@ -676,10 +676,11 @@ function B(e, t) {
676
676
  return e;
677
677
  }
678
678
  }
679
- async function V(e, t) {
680
- let n = await fetch(e, { signal: t });
681
- if (!n.ok) throw Error(`Failed to fetch thumbnail VTT: ${n.status}`);
682
- return z(await n.text()).map((t) => (t.src = B(t.src, n.url || e), t));
679
+ async function V(e, t, n) {
680
+ let r = await fetch(e, { signal: t });
681
+ if (!r.ok) throw Error(`Failed to fetch thumbnail VTT: ${r.status}`);
682
+ let i = r.url || e, a = await r.text();
683
+ return z(n ? await n(a, i) : a).map((e) => (e.src = B(e.src, i), e));
683
684
  }
684
685
  function H(e, t) {
685
686
  if (e.length === 0) return null;
@@ -1117,7 +1118,7 @@ function Y(e) {
1117
1118
  return;
1118
1119
  }
1119
1120
  let t = new AbortController();
1120
- C = t, V(e, t.signal).then((e) => {
1121
+ C = t, V(e, t.signal, i.transformThumbnailVTT).then((e) => {
1121
1122
  t.signal.aborted || r.setState((t) => ({
1122
1123
  ...t,
1123
1124
  thumbnailCues: e
@@ -1250,7 +1251,7 @@ function Y(e) {
1250
1251
  hotkeys: l,
1251
1252
  engine: null,
1252
1253
  updateOptions(e) {
1253
- let t = typeof e.src == "string" && e.src !== i.src, n = Object.hasOwn(e, "type") && e.type !== i.type;
1254
+ let t = typeof e.src == "string" && e.src !== i.src, n = Object.hasOwn(e, "type") && e.type !== i.type, a = Object.hasOwn(e, "thumbnails") && e.thumbnails !== i.thumbnails;
1254
1255
  i = {
1255
1256
  ...i,
1256
1257
  ...e
@@ -1263,7 +1264,7 @@ function Y(e) {
1263
1264
  activeSubtitle: e.subtitles ? t.activeSubtitle && e.subtitles.some((e) => e.lang === t.activeSubtitle.lang) ? t.activeSubtitle : e.subtitles.find((e) => e.default) ?? e.subtitles[0] ?? null : t.activeSubtitle,
1264
1265
  activeQuality: e.qualities ? e.qualities.includes(t.activeQuality) ? t.activeQuality : e.qualities[0] ?? "Auto" : t.activeQuality
1265
1266
  };
1266
- }), Object.hasOwn(e, "thumbnails") && I(e.thumbnails), (t || n) && H();
1267
+ }), a && I(e.thumbnails), (t || n) && H();
1267
1268
  },
1268
1269
  setThumbnails(e) {
1269
1270
  i = {
@@ -36,6 +36,6 @@ export interface ThumbnailCue {
36
36
  }
37
37
  /** Parse a VTT thumbnail sprite file into cues */
38
38
  export declare function parseThumbnailVTT(content: string): ThumbnailCue[];
39
- export declare function fetchThumbnails(url: string, signal?: AbortSignal): Promise<ThumbnailCue[]>;
39
+ export declare function fetchThumbnails(url: string, signal?: AbortSignal, transform?: (content: string, responseUrl: string) => string | Promise<string>): Promise<ThumbnailCue[]>;
40
40
  /** Find the matching thumbnail cue for a given time */
41
41
  export declare function getThumbnailAtTime(cues: ThumbnailCue[], time: number): ThumbnailCue | null;
package/dist/types.d.ts CHANGED
@@ -47,6 +47,8 @@ export interface PlayerOptions {
47
47
  qualities?: string[];
48
48
  autoPlay?: boolean;
49
49
  thumbnails?: string;
50
+ /** Transform raw thumbnail VTT content before it is parsed. */
51
+ transformThumbnailVTT?: TransformThumbnailVTT;
50
52
  lang?: string;
51
53
  translations?: Record<string, string>;
52
54
  plugins?: PlayerPlugin[];
@@ -86,6 +88,7 @@ export interface PlayerOptions {
86
88
  */
87
89
  engine?: MediaEngine | ((video: HTMLVideoElement) => MediaEngine);
88
90
  }
91
+ export type TransformThumbnailVTT = (content: string, responseUrl: string) => string | Promise<string>;
89
92
  export type { PlaybackStatus };
90
93
  export type { MediaCapabilitiesSnapshot, PlayerSource };
91
94
  export interface PlayerError {
@@ -169,7 +172,7 @@ export interface PlayerInstance {
169
172
  hotkeys: HotkeyRegistry;
170
173
  /** The active media engine. Null before mount and after unmount. */
171
174
  engine: MediaEngine | null;
172
- updateOptions(opts: Partial<Pick<PlayerOptions, 'src' | 'type' | 'poster' | 'autoPlay' | 'subtitles' | 'qualities' | 'thumbnails'>>): void;
175
+ updateOptions(opts: Partial<Pick<PlayerOptions, 'src' | 'type' | 'poster' | 'autoPlay' | 'subtitles' | 'qualities' | 'thumbnails' | 'transformThumbnailVTT'>>): void;
173
176
  setThumbnails(url?: string): void;
174
177
  initPlugins(plugins: PlayerPlugin[]): () => void;
175
178
  mount(videoEl: HTMLVideoElement, containerEl: HTMLDivElement): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vplayer/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",