@viostream/viostream-player-vue 0.1.1

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,478 @@
1
+ # viostream-player-vue
2
+
3
+ <a href="https://www.npmjs.com/package/@viostream/viostream-player-vue"><img src="https://img.shields.io/npm/v/@viostream/viostream-player-vue.svg?sanitize=true" alt="npm version"></a>
4
+ <a href="https://www.npmjs.com/package/@viostream/viostream-player-vue"><img src="https://img.shields.io/npm/l/@viostream/viostream-player-vue.svg?sanitize=true" alt="License"></a>
5
+ <a href="https://npmcharts.com/compare/@viostream/viostream-player-vue?interval=30"><img src="https://img.shields.io/npm/dm/@viostream/viostream-player-vue.svg?sanitize=true" alt="Downloads"></a>
6
+
7
+ Vue 3 SDK for the [Viostream](https://www.viostream.com) video player. Embed, control, and listen to player events with full TypeScript support.
8
+
9
+ ## Requirements
10
+
11
+ - Vue 3.3+
12
+ - A Viostream account key (found on the **Settings > General** page in Viostream)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @viostream/viostream-player-vue
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Component
23
+
24
+ Drop a `<ViostreamPlayer>` into any Vue component. The SDK loads the Viostream script automatically.
25
+
26
+ ```vue
27
+ <script setup lang="ts">
28
+ import { ViostreamPlayer } from '@viostream/viostream-player-vue';
29
+ </script>
30
+
31
+ <template>
32
+ <ViostreamPlayer
33
+ account-key="vc-100100100"
34
+ public-key="nhedxonrxsyfee"
35
+ :display-title="true"
36
+ :sharing="true"
37
+ @play="console.log('playing')"
38
+ />
39
+ </template>
40
+ ```
41
+
42
+ ### Headless / Programmatic
43
+
44
+ Use `createViostreamPlayer` when you need full control without a component:
45
+
46
+ ```ts
47
+ import { createViostreamPlayer } from '@viostream/viostream-player-vue';
48
+
49
+ const player = await createViostreamPlayer({
50
+ accountKey: 'vc-100100100',
51
+ publicKey: 'nhedxonrxsyfee',
52
+ target: 'my-video-div', // element id or HTMLElement
53
+ options: { displayTitle: true }
54
+ });
55
+
56
+ player.play();
57
+ ```
58
+
59
+ ---
60
+
61
+ ## `<ViostreamPlayer>` Component
62
+
63
+ ### Props
64
+
65
+ #### Required
66
+
67
+ | Prop | Type | Description |
68
+ |---|---|---|
69
+ | `account-key` | `string` | Your Viostream account key (e.g. `'vc-100100100'`). |
70
+ | `public-key` | `string` | The public key of the media asset to embed. |
71
+
72
+ #### Embed Options
73
+
74
+ All embed options are optional and passed directly to the Viostream embed API.
75
+
76
+ | Prop | Type | Description |
77
+ |---|---|---|
78
+ | `chapters` | `boolean` | Display chapter markers. |
79
+ | `chapter-display-type` | `'dropdown' \| 'progressbar' \| 'horizontal'` | Chapter display style. |
80
+ | `chapter-slug` | `string` | Seek to a named chapter before playback. |
81
+ | `display-title` | `boolean` | Show the video title overlay. |
82
+ | `hls-quality-selector` | `boolean` | Show the HLS quality selector. |
83
+ | `player-key` | `string` | Override the player theme to use. |
84
+ | `sharing` | `boolean` | Show sharing controls. |
85
+ | `speed-selector` | `boolean` | Show playback speed selector. |
86
+ | `start-end-timespan` | `string` | Play a specific section (e.g. `'10,30'`). |
87
+ | `start-time` | `string` | Seek to a time (seconds) before playback. |
88
+ | `transcript-download` | `boolean` | Allow transcript download. |
89
+
90
+ #### Events
91
+
92
+ | Event | Payload | Fires when |
93
+ |---|---|---|
94
+ | `@play` | — | Playback starts or resumes. |
95
+ | `@pause` | — | Playback is paused. |
96
+ | `@ended` | — | Media finishes playing. |
97
+ | `@time-update` | `ViostreamTimeUpdateData` | Current time changes. `.seconds`, `.duration`. |
98
+ | `@volume-change` | `ViostreamVolumeChangeData` | Volume changes. `.volume`. |
99
+ | `@error` | `ViostreamErrorData` | An error occurs. `.code`, `.message`. |
100
+ | `@progress` | `ViostreamProgressData` | Buffering progress. `.percent`. |
101
+ | `@ready` | — | Player is ready. |
102
+ | `@seeked` | — | Seek operation completes. |
103
+ | `@loaded` | — | Metadata has loaded. |
104
+
105
+ #### Other Props
106
+
107
+ | Prop | Type | Description |
108
+ |---|---|---|
109
+ | `class` | `string` | CSS class applied to the outer wrapper `<div>`. |
110
+ | `@player-ready` | `(player: ViostreamPlayerInstance) => void` | Event providing the player instance for programmatic control. |
111
+
112
+ #### Slots
113
+
114
+ | Slot | Scoped Props | Description |
115
+ |---|---|---|
116
+ | `loading` | — | Custom content shown while the player is loading. |
117
+ | `error` | `{ message: string }` | Custom error display. Receives the error message. |
118
+
119
+ ### Getting the Player Instance
120
+
121
+ Use `@player-ready` to get a reference to the player for programmatic control:
122
+
123
+ ```vue
124
+ <script setup lang="ts">
125
+ import { ref } from 'vue';
126
+ import { ViostreamPlayer } from '@viostream/viostream-player-vue';
127
+ import type { ViostreamPlayerInstance } from '@viostream/viostream-player-vue';
128
+
129
+ const player = ref<ViostreamPlayerInstance>();
130
+ </script>
131
+
132
+ <template>
133
+ <ViostreamPlayer
134
+ account-key="vc-100100100"
135
+ public-key="nhedxonrxsyfee"
136
+ @player-ready="(p) => (player = p)"
137
+ />
138
+
139
+ <button @click="player?.play()">Play</button>
140
+ <button @click="player?.pause()">Pause</button>
141
+ </template>
142
+ ```
143
+
144
+ ### Custom Loading and Error States
145
+
146
+ Use slots to replace the default loading/error UI:
147
+
148
+ ```vue
149
+ <ViostreamPlayer
150
+ account-key="vc-100100100"
151
+ public-key="nhedxonrxsyfee"
152
+ >
153
+ <template #loading>
154
+ <p>Loading video...</p>
155
+ </template>
156
+
157
+ <template #error="{ message }">
158
+ <div class="my-error">Something went wrong: {{ message }}</div>
159
+ </template>
160
+ </ViostreamPlayer>
161
+ ```
162
+
163
+ ### Cleanup
164
+
165
+ The player is destroyed automatically when the component unmounts. All event listeners are cleaned up and the player iframe is removed from the DOM.
166
+
167
+ ---
168
+
169
+ ## `createViostreamPlayer()`
170
+
171
+ For use outside of Vue components or when you need full lifecycle control.
172
+
173
+ ```ts
174
+ import { createViostreamPlayer } from '@viostream/viostream-player-vue';
175
+ import type { CreateViostreamPlayerOptions } from '@viostream/viostream-player-vue';
176
+
177
+ const player = await createViostreamPlayer({
178
+ accountKey: 'vc-100100100',
179
+ publicKey: 'nhedxonrxsyfee',
180
+ target: 'my-video-div', // element id (string) or HTMLElement
181
+ options: {
182
+ displayTitle: true,
183
+ sharing: true,
184
+ speedSelector: true
185
+ }
186
+ });
187
+ ```
188
+
189
+ ### Options
190
+
191
+ | Property | Type | Description |
192
+ |---|---|---|
193
+ | `accountKey` | `string` | Your Viostream account key. |
194
+ | `publicKey` | `string` | Public key of the media asset. |
195
+ | `target` | `string \| HTMLElement` | Container element id or direct DOM reference. |
196
+ | `options` | `ViostreamEmbedOptions` | Embed options (same as component props above). |
197
+
198
+ ---
199
+
200
+ ## Player Instance API
201
+
202
+ Both the component (via `@player-ready`) and `createViostreamPlayer()` provide a `ViostreamPlayerInstance` with the following methods.
203
+
204
+ ### Playback Controls
205
+
206
+ ```ts
207
+ player.play();
208
+ player.pause();
209
+ player.mute();
210
+ player.unmute();
211
+ player.setVolume(0.5); // 0 to 1
212
+ player.setLoop(true);
213
+ player.setCurrentTime(30); // seek to 30 seconds
214
+ player.setCurrentTime(30, true); // seek and auto-play
215
+ player.reload(); // reload the player
216
+ player.reload({ key: 'value' }); // reload with new settings
217
+ ```
218
+
219
+ ### Getters (Promise-based)
220
+
221
+ All getters return promises. The SDK converts the underlying callback-based API to `async`/`await`.
222
+
223
+ ```ts
224
+ const volume = await player.getVolume(); // number (0-1)
225
+ const loop = await player.getLoop(); // boolean
226
+ const time = await player.getCurrentTime(); // number (seconds)
227
+ const paused = await player.getPaused(); // boolean
228
+ const duration = await player.getDuration(); // number (seconds)
229
+ const muted = await player.getMuted(); // boolean
230
+ const ratio = await player.getAspectRatio(); // number
231
+ const liveTime = await player.getLiveCurrentTime(); // number (seconds)
232
+ const height = await player.getHeight(); // number (pixels)
233
+ const tracks = await player.getTracks(); // ViostreamTrack[]
234
+ ```
235
+
236
+ ### Track Management
237
+
238
+ ```ts
239
+ const tracks = await player.getTracks();
240
+ player.setTrack(tracks[0]); // pass a ViostreamTrack object
241
+ player.setTrack('en'); // or a track id string
242
+ ```
243
+
244
+ ### Cue Management
245
+
246
+ ```ts
247
+ player.cueAdd({ startTime: 10, text: 'Introduction' });
248
+
249
+ player.cueUpdate(
250
+ { startTime: 10, text: 'Introduction' },
251
+ { text: 'Updated Introduction' }
252
+ );
253
+
254
+ player.cueDelete('cue-id');
255
+ ```
256
+
257
+ ### Automatic Speech Recognition (ASR)
258
+
259
+ ```ts
260
+ player.asrAdd(cueArray, 'asr-track-id');
261
+ ```
262
+
263
+ ### Events
264
+
265
+ Subscribe to player events with `on()`. It returns an unsubscribe function.
266
+
267
+ ```ts
268
+ // Subscribe
269
+ const unsubscribe = player.on('timeupdate', (data) => {
270
+ console.log(`${data.seconds}s / ${data.duration}s`);
271
+ });
272
+
273
+ // Unsubscribe later
274
+ unsubscribe();
275
+
276
+ // Or use off() directly
277
+ const handler = () => console.log('paused');
278
+ player.on('pause', handler);
279
+ player.off('pause', handler);
280
+ ```
281
+
282
+ #### Available Events
283
+
284
+ | Event | Callback Data | Description |
285
+ |---|---|---|
286
+ | `play` | `void` | Playback started or resumed. |
287
+ | `pause` | `void` | Playback paused. |
288
+ | `ended` | `void` | Media finished playing. |
289
+ | `timeupdate` | `{ seconds: number, duration: number }` | Playback time changed. |
290
+ | `volumechange` | `{ volume: number }` | Volume changed. |
291
+ | `error` | `{ code?: number, message?: string }` | Error occurred. |
292
+ | `progress` | `{ percent: number }` | Buffering progress. |
293
+ | `ready` | `void` | Player is ready. |
294
+ | `seeked` | `void` | Seek completed. |
295
+ | `loaded` | `void` | Metadata loaded. |
296
+
297
+ Custom event names are also accepted via the string index signature:
298
+
299
+ ```ts
300
+ player.on('my-custom-event', (data) => {
301
+ console.log(data);
302
+ });
303
+ ```
304
+
305
+ ### Destroy
306
+
307
+ When using `createViostreamPlayer()`, you are responsible for cleanup:
308
+
309
+ ```ts
310
+ player.destroy();
311
+ ```
312
+
313
+ After calling `destroy()`:
314
+ - All event listeners are removed.
315
+ - The player iframe is removed from the DOM.
316
+ - Getter calls will reject with `"Player has been destroyed"`.
317
+ - `player.raw` returns `undefined`.
318
+
319
+ ### Raw Escape Hatch
320
+
321
+ If you need direct access to the underlying Viostream player instance:
322
+
323
+ ```ts
324
+ const raw = player.raw; // RawViostreamPlayerInstance | undefined
325
+ if (raw) {
326
+ raw.getVolume((vol) => console.log(vol)); // callback-based original API
327
+ }
328
+ ```
329
+
330
+ ---
331
+
332
+ ## Script Loader
333
+
334
+ The SDK loads the Viostream API script automatically. If you need manual control over loading (e.g. preloading), you can use `loadViostream` directly:
335
+
336
+ ```ts
337
+ import { loadViostream } from '@viostream/viostream-player-vue';
338
+
339
+ const api = await loadViostream('vc-100100100');
340
+ // api.embed(...) is now available
341
+ ```
342
+
343
+ The loader:
344
+ - Injects `<script src="https://play.viostream.com/api/{accountKey}">` into `<head>`.
345
+ - Deduplicates requests -- calling it multiple times with the same key returns the same promise.
346
+ - Times out after 15 seconds if the script fails to load.
347
+ - Detects if the script tag already exists in the DOM (e.g. added manually) and waits for it.
348
+
349
+ ---
350
+
351
+ ## TypeScript
352
+
353
+ Every export is fully typed. Import types alongside runtime exports:
354
+
355
+ ```ts
356
+ import { ViostreamPlayer, createViostreamPlayer } from '@viostream/viostream-player-vue';
357
+ import type {
358
+ ViostreamPlayerInstance,
359
+ ViostreamPlayerProps,
360
+ ViostreamPlayerEventProps,
361
+ ViostreamEmbedOptions,
362
+ ViostreamTimeUpdateData,
363
+ ViostreamVolumeChangeData,
364
+ ViostreamErrorData,
365
+ ViostreamProgressData,
366
+ ViostreamPlayerEventMap,
367
+ ViostreamEventHandler,
368
+ ViostreamCue,
369
+ ViostreamCueFieldUpdate,
370
+ ViostreamTrack,
371
+ CreateViostreamPlayerOptions,
372
+ RawViostreamPlayerInstance,
373
+ ViostreamGlobal
374
+ } from '@viostream/viostream-player-vue';
375
+ ```
376
+
377
+ ---
378
+
379
+ ## Full Example
380
+
381
+ A complete example showing the component with custom controls, event logging, and async getters:
382
+
383
+ ```vue
384
+ <script setup lang="ts">
385
+ import { ref, computed } from 'vue';
386
+ import { ViostreamPlayer } from '@viostream/viostream-player-vue';
387
+ import type {
388
+ ViostreamPlayerInstance,
389
+ ViostreamTimeUpdateData,
390
+ } from '@viostream/viostream-player-vue';
391
+
392
+ const player = ref<ViostreamPlayerInstance>();
393
+ const currentTime = ref(0);
394
+ const duration = ref(0);
395
+ const paused = ref(true);
396
+ const log = ref<string[]>([]);
397
+
398
+ function addLog(msg: string) {
399
+ log.value = [msg, ...log.value.slice(0, 49)];
400
+ }
401
+
402
+ function handleReady(p: ViostreamPlayerInstance) {
403
+ player.value = p;
404
+ p.getDuration().then((d) => (duration.value = d));
405
+ }
406
+
407
+ function handleTimeUpdate(data: ViostreamTimeUpdateData) {
408
+ currentTime.value = data.seconds;
409
+ duration.value = data.duration;
410
+ }
411
+
412
+ function format(s: number): string {
413
+ return `${Math.floor(s / 60)}:${Math.floor(s % 60).toString().padStart(2, '0')}`;
414
+ }
415
+ </script>
416
+
417
+ <template>
418
+ <ViostreamPlayer
419
+ account-key="vc-100100100"
420
+ public-key="nhedxonrxsyfee"
421
+ :display-title="true"
422
+ :sharing="true"
423
+ :speed-selector="true"
424
+ :hls-quality-selector="true"
425
+ @play="() => { paused = false; addLog('play'); }"
426
+ @pause="() => { paused = true; addLog('pause'); }"
427
+ @ended="() => addLog('ended')"
428
+ @time-update="handleTimeUpdate"
429
+ @player-ready="handleReady"
430
+ />
431
+
432
+ <div>
433
+ <button @click="paused ? player?.play() : player?.pause()">
434
+ {{ paused ? 'Play' : 'Pause' }}
435
+ </button>
436
+ <button @click="player?.setCurrentTime(0)">Restart</button>
437
+ <span>{{ format(currentTime) }} / {{ format(duration) }}</span>
438
+ </div>
439
+
440
+ <div>
441
+ <button @click="async () => {
442
+ const vol = await player?.getVolume();
443
+ addLog(`volume: ${vol}`);
444
+ }">Get Volume</button>
445
+ <button @click="async () => {
446
+ const tracks = await player?.getTracks();
447
+ addLog(`tracks: ${JSON.stringify(tracks)}`);
448
+ }">Get Tracks</button>
449
+ </div>
450
+
451
+ <pre>{{ log.join('\n') }}</pre>
452
+ </template>
453
+ ```
454
+
455
+ ---
456
+
457
+ ## Development
458
+
459
+ ```bash
460
+ # Install dependencies
461
+ npm install
462
+
463
+ # Build (compile and bundle to dist/)
464
+ npm run build
465
+
466
+ # Type-check
467
+ npm run check
468
+
469
+ # Run tests
470
+ npm run test
471
+
472
+ # Run tests in watch mode
473
+ npm run test:watch
474
+ ```
475
+
476
+ ## License
477
+
478
+ MIT
@@ -0,0 +1,84 @@
1
+ import { ViostreamPlayer, ViostreamTimeUpdateData, ViostreamVolumeChangeData, ViostreamErrorData, ViostreamProgressData } from '@viostream/viostream-player-core';
2
+ type __VLS_Props = {
3
+ accountKey: string;
4
+ publicKey: string;
5
+ chapters?: boolean;
6
+ chapterDisplayType?: 'progressbar';
7
+ chapterSlug?: string;
8
+ displayTitle?: boolean;
9
+ hlsQualitySelector?: boolean;
10
+ playerKey?: string;
11
+ sharing?: boolean;
12
+ speedSelector?: boolean;
13
+ startEndTimespan?: string;
14
+ startTime?: string;
15
+ transcriptDownload?: boolean;
16
+ class?: string;
17
+ };
18
+ declare function __VLS_template(): {
19
+ attrs: Partial<{}>;
20
+ slots: Readonly<{
21
+ loading?: () => unknown;
22
+ error?: (props: {
23
+ message: string;
24
+ }) => unknown;
25
+ }> & {
26
+ loading?: () => unknown;
27
+ error?: (props: {
28
+ message: string;
29
+ }) => unknown;
30
+ };
31
+ refs: {
32
+ containerRef: HTMLDivElement;
33
+ };
34
+ rootEl: HTMLDivElement;
35
+ };
36
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
37
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
38
+ play: () => any;
39
+ pause: () => any;
40
+ ended: () => any;
41
+ timeUpdate: (data: ViostreamTimeUpdateData) => any;
42
+ volumeChange: (data: ViostreamVolumeChangeData) => any;
43
+ error: (data: ViostreamErrorData) => any;
44
+ progress: (data: ViostreamProgressData) => any;
45
+ ready: () => any;
46
+ seeked: () => any;
47
+ loaded: () => any;
48
+ playerReady: (player: ViostreamPlayer) => any;
49
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
50
+ onPlay?: (() => any) | undefined;
51
+ onPause?: (() => any) | undefined;
52
+ onEnded?: (() => any) | undefined;
53
+ onTimeUpdate?: ((data: ViostreamTimeUpdateData) => any) | undefined;
54
+ onVolumeChange?: ((data: ViostreamVolumeChangeData) => any) | undefined;
55
+ onError?: ((data: ViostreamErrorData) => any) | undefined;
56
+ onProgress?: ((data: ViostreamProgressData) => any) | undefined;
57
+ onReady?: (() => any) | undefined;
58
+ onSeeked?: (() => any) | undefined;
59
+ onLoaded?: (() => any) | undefined;
60
+ onPlayerReady?: ((player: ViostreamPlayer) => any) | undefined;
61
+ }>, {
62
+ chapters: boolean;
63
+ chapterDisplayType: "progressbar";
64
+ chapterSlug: string;
65
+ displayTitle: boolean;
66
+ hlsQualitySelector: boolean;
67
+ playerKey: string;
68
+ sharing: boolean;
69
+ speedSelector: boolean;
70
+ startEndTimespan: string;
71
+ startTime: string;
72
+ transcriptDownload: boolean;
73
+ class: string;
74
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
75
+ containerRef: HTMLDivElement;
76
+ }, HTMLDivElement>;
77
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
78
+ export default _default;
79
+ type __VLS_WithTemplateSlots<T, S> = T & {
80
+ new (): {
81
+ $slots: S;
82
+ };
83
+ };
84
+ //# sourceMappingURL=ViostreamPlayer.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViostreamPlayer.vue.d.ts","sourceRoot":"","sources":["../src/ViostreamPlayer.vue"],"names":[],"mappings":"AAMA;AA8OA,OAAO,KAAK,EAEV,eAAe,EAGf,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAM1C,KAAK,WAAW,GAAG;IAEjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAG7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA2LF,iBAAS,cAAc;WAuCT,OAAO,IAA6B;;kBA1LtC,MAAM,OAAO;gBACf,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO;;kBADrC,MAAM,OAAO;gBACf,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO;;;;;;EA8LhD;AAcD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;cApQR,OAAO;wBACG,aAAa;iBACpB,MAAM;kBACL,OAAO;wBACD,OAAO;eAChB,MAAM;aACR,OAAO;mBACD,OAAO;sBACJ,MAAM;eACb,MAAM;wBACG,OAAO;WAGpB,MAAM;;;kBAiQd,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @viostream/viostream-player-vue
3
+ *
4
+ * Vue 3 SDK for the Viostream video player.
5
+ *
6
+ * @example Component usage
7
+ * ```vue
8
+ * <script setup lang="ts">
9
+ * import { ViostreamPlayer } from '@viostream/viostream-player-vue';
10
+ * </script>
11
+ *
12
+ * <template>
13
+ * <ViostreamPlayer
14
+ * account-key="vc-100100100"
15
+ * public-key="nhedxonrxsyfee"
16
+ * :display-title="true"
17
+ * @play="console.log('playing')"
18
+ * />
19
+ * </template>
20
+ * ```
21
+ *
22
+ * @example Headless / programmatic usage
23
+ * ```ts
24
+ * import { createViostreamPlayer } from '@viostream/viostream-player-vue';
25
+ *
26
+ * const player = await createViostreamPlayer({
27
+ * accountKey: 'vc-100100100',
28
+ * publicKey: 'nhedxonrxsyfee',
29
+ * target: 'my-video-div'
30
+ * });
31
+ *
32
+ * player.play();
33
+ * const time = await player.getCurrentTime();
34
+ * player.on('ended', () => console.log('done'));
35
+ * ```
36
+ */
37
+ export { default as ViostreamPlayer } from './ViostreamPlayer.vue';
38
+ export { createViostreamPlayer, wrapRawPlayer, loadViostream, } from '@viostream/viostream-player-core';
39
+ export type { CreateViostreamPlayerOptions, ViostreamEmbedOptions, ViostreamTimeUpdateData, ViostreamVolumeChangeData, ViostreamErrorData, ViostreamProgressData, ViostreamPlayerEventMap, ViostreamEventHandler, ViostreamCue, ViostreamCueFieldUpdate, ViostreamTrack, ViostreamPlayer as ViostreamPlayerInstance, RawViostreamPlayerInstance, ViostreamGlobal, } from '@viostream/viostream-player-core';
40
+ export type { ViostreamPlayerProps, ViostreamPlayerEventProps, } from './types.js';
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,aAAa,GACd,MAAM,kCAAkC,CAAC;AAE1C,YAAY,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,eAAe,IAAI,uBAAuB,EAC1C,0BAA0B,EAC1B,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EACV,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,113 @@
1
+ import { defineComponent as V, ref as l, onMounted as _, onUnmounted as D, openBlock as K, createElementBlock as B, normalizeClass as P, renderSlot as m, createCommentVNode as f, createElementVNode as C, toDisplayString as R } from "vue";
2
+ import { loadViostream as N, wrapRawPlayer as M } from "@viostream/viostream-player-core";
3
+ import { createViostreamPlayer as F, loadViostream as I, wrapRawPlayer as L } from "@viostream/viostream-player-core";
4
+ const U = ["data-viostream-public-key"], Q = {
5
+ "data-viostream-error": "",
6
+ style: { color: "red", padding: "1em" }
7
+ }, O = /* @__PURE__ */ V({
8
+ __name: "ViostreamPlayer",
9
+ props: {
10
+ accountKey: {},
11
+ publicKey: {},
12
+ chapters: { type: Boolean, default: void 0 },
13
+ chapterDisplayType: { default: void 0 },
14
+ chapterSlug: { default: void 0 },
15
+ displayTitle: { type: Boolean, default: void 0 },
16
+ hlsQualitySelector: { type: Boolean, default: void 0 },
17
+ playerKey: { default: void 0 },
18
+ sharing: { type: Boolean, default: void 0 },
19
+ speedSelector: { type: Boolean, default: void 0 },
20
+ startEndTimespan: { default: void 0 },
21
+ startTime: { default: void 0 },
22
+ transcriptDownload: { type: Boolean, default: void 0 },
23
+ class: { default: void 0 }
24
+ },
25
+ emits: ["play", "pause", "ended", "timeUpdate", "volumeChange", "error", "progress", "ready", "seeked", "loaded", "playerReady"],
26
+ setup(y, { emit: v }) {
27
+ const a = y, t = v, d = `viostream-player-${Math.random().toString(36).slice(2, 10)}`, h = l(), n = l(), o = l(), p = l(!0);
28
+ let s = !1;
29
+ const c = [];
30
+ function g() {
31
+ const e = {};
32
+ return a.chapters !== void 0 && (e.chapters = a.chapters), a.chapterDisplayType !== void 0 && (e.chapterDisplayType = a.chapterDisplayType), a.chapterSlug !== void 0 && (e.chapterSlug = a.chapterSlug), a.displayTitle !== void 0 && (e.displayTitle = a.displayTitle), a.hlsQualitySelector !== void 0 && (e.hlsQualitySelector = a.hlsQualitySelector), a.playerKey !== void 0 && (e.playerKey = a.playerKey), a.sharing !== void 0 && (e.sharing = a.sharing), a.speedSelector !== void 0 && (e.speedSelector = a.speedSelector), a.startEndTimespan !== void 0 && (e.startEndTimespan = a.startEndTimespan), a.startTime !== void 0 && (e.startTime = a.startTime), a.transcriptDownload !== void 0 && (e.transcriptDownload = a.transcriptDownload), e;
33
+ }
34
+ const T = [
35
+ ["play", () => t("play")],
36
+ ["pause", () => t("pause")],
37
+ ["ended", () => t("ended")],
38
+ ["timeUpdate", (e) => t("timeUpdate", e)],
39
+ ["volumeChange", (e) => t("volumeChange", e)],
40
+ ["error", (e) => t("error", e)],
41
+ ["progress", (e) => t("progress", e)],
42
+ ["ready", () => t("ready")],
43
+ ["seeked", () => t("seeked")],
44
+ ["loaded", () => t("loaded")]
45
+ ], S = {
46
+ play: "play",
47
+ pause: "pause",
48
+ ended: "ended",
49
+ timeUpdate: "timeupdate",
50
+ volumeChange: "volumechange",
51
+ error: "error",
52
+ progress: "progress",
53
+ ready: "ready",
54
+ seeked: "seeked",
55
+ loaded: "loaded"
56
+ };
57
+ function w(e) {
58
+ for (const [i, u] of T) {
59
+ const r = S[i];
60
+ if (r) {
61
+ const k = e.on(r, u);
62
+ c.push(k);
63
+ }
64
+ }
65
+ }
66
+ function E() {
67
+ for (const e of c)
68
+ e();
69
+ c.length = 0;
70
+ }
71
+ async function b() {
72
+ try {
73
+ const e = await N(a.accountKey);
74
+ if (s) return;
75
+ const i = g(), u = e.embed(a.publicKey, d, i), r = M(u, d);
76
+ if (s) {
77
+ r.destroy();
78
+ return;
79
+ }
80
+ n.value = r, p.value = !1, w(r), t("playerReady", r);
81
+ } catch (e) {
82
+ s || (o.value = e instanceof Error ? e.message : String(e), p.value = !1);
83
+ }
84
+ }
85
+ return _(() => {
86
+ b();
87
+ }), D(() => {
88
+ var e;
89
+ s = !0, E(), (e = n.value) == null || e.destroy(), n.value = void 0;
90
+ }), (e, i) => (K(), B("div", {
91
+ id: d,
92
+ class: P(a.class),
93
+ ref_key: "containerRef",
94
+ ref: h,
95
+ "data-viostream-player": "",
96
+ "data-viostream-public-key": y.publicKey
97
+ }, [
98
+ p.value ? m(e.$slots, "loading", { key: 0 }) : f("", !0),
99
+ o.value ? m(e.$slots, "error", {
100
+ key: 1,
101
+ message: o.value
102
+ }, () => [
103
+ C("div", Q, " Failed to load Viostream player: " + R(o.value), 1)
104
+ ]) : f("", !0)
105
+ ], 10, U));
106
+ }
107
+ });
108
+ export {
109
+ O as ViostreamPlayer,
110
+ F as createViostreamPlayer,
111
+ I as loadViostream,
112
+ L as wrapRawPlayer
113
+ };
@@ -0,0 +1,30 @@
1
+ import { ViostreamEmbedOptions, ViostreamPlayer, ViostreamTimeUpdateData, ViostreamVolumeChangeData, ViostreamErrorData, ViostreamProgressData } from '@viostream/viostream-player-core';
2
+ /** Callback props for player events on the `<ViostreamPlayer>` component. */
3
+ export interface ViostreamPlayerEventProps {
4
+ onPlay?: () => void;
5
+ onPause?: () => void;
6
+ onEnded?: () => void;
7
+ onTimeUpdate?: (data: ViostreamTimeUpdateData) => void;
8
+ onVolumeChange?: (data: ViostreamVolumeChangeData) => void;
9
+ onError?: (data: ViostreamErrorData) => void;
10
+ onProgress?: (data: ViostreamProgressData) => void;
11
+ onReady?: () => void;
12
+ onSeeked?: () => void;
13
+ onLoaded?: () => void;
14
+ }
15
+ /** Props accepted by the `<ViostreamPlayer>` component. */
16
+ export interface ViostreamPlayerProps extends ViostreamEmbedOptions, ViostreamPlayerEventProps {
17
+ /** Your Viostream account key (e.g. `'vc-100100100'`). */
18
+ accountKey: string;
19
+ /** The public key of the media asset to embed. */
20
+ publicKey: string;
21
+ /**
22
+ * Optional CSS class applied to the outer wrapper `<div>`.
23
+ */
24
+ class?: string;
25
+ /**
26
+ * Callback fired once the player is ready, providing the `ViostreamPlayer` instance.
27
+ */
28
+ onPlayerReady?: (player: ViostreamPlayer) => void;
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAM1C,6EAA6E;AAC7E,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAC3D,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,2DAA2D;AAC3D,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB,EAAE,yBAAyB;IAC5F,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACnD"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@viostream/viostream-player-vue",
3
+ "version": "0.1.1",
4
+ "description": "Vue 3 SDK for the Viostream video player — embed, control, and listen to player events",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "scripts": {
11
+ "build": "vue-tsc -b && vite build",
12
+ "check": "vue-tsc --noEmit",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "!dist/**/*.test.*",
28
+ "!dist/**/*.spec.*"
29
+ ],
30
+ "dependencies": {
31
+ "@viostream/viostream-player-core": "^0.1.2"
32
+ },
33
+ "peerDependencies": {
34
+ "vue": "^3.3.0"
35
+ },
36
+ "devDependencies": {
37
+ "@testing-library/jest-dom": "^6.9.1",
38
+ "@testing-library/vue": "^8.1.0",
39
+ "@vitejs/plugin-vue": "^5.2.0",
40
+ "jsdom": "^28.1.0",
41
+ "typescript": "^5.7.0",
42
+ "vite": "^6.0.0",
43
+ "vite-plugin-dts": "^4.5.0",
44
+ "vitest": "^4.0.18",
45
+ "vue": "^3.5.0",
46
+ "vue-tsc": "^2.2.0"
47
+ },
48
+ "keywords": [
49
+ "vue",
50
+ "vue3",
51
+ "viostream",
52
+ "video",
53
+ "player",
54
+ "embed",
55
+ "sdk"
56
+ ]
57
+ }