@hopecloud/jetstream-player 0.2.3 → 0.2.5

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.
@@ -1,10 +1,20 @@
1
+ export declare let embedVideosSrc: string[];
1
2
  type CallbackType = (index: number) => void;
2
3
  export declare const onEnded: (callback: CallbackType) => void;
3
4
  export declare const playVideo: (callback: CallbackType) => void;
4
5
  export declare const pauseVideo: (callback: CallbackType) => void;
5
- export declare const initPlayerMethods: () => void;
6
- export declare const embedPlayer: {
7
- play: (index: number) => void;
8
- pause: (index: number) => void;
6
+ export declare const initPlayerMethods: () => {
7
+ new (selector: string): {
8
+ iframe: HTMLIFrameElement;
9
+ play(): void;
10
+ pause(): void;
11
+ };
12
+ };
13
+ export declare const JetstreamPlayer: {
14
+ new (selector: string): {
15
+ iframe: HTMLIFrameElement;
16
+ play(): void;
17
+ pause(): void;
18
+ };
9
19
  };
10
20
  export {};
@@ -1,6 +1,6 @@
1
1
  let iframesWithEmbedVideo = [];
2
2
  let allIframes = [];
3
- let embedVideosSrc = [];
3
+ export let embedVideosSrc = [];
4
4
  const callbacks = {};
5
5
  export const onEnded = (callback) => {
6
6
  callbacks.onEnded = callback;
@@ -32,16 +32,19 @@ export const initPlayerMethods = () => {
32
32
  }
33
33
  }
34
34
  });
35
+ class JetstreamPlayer {
36
+ iframe;
37
+ constructor(selector) {
38
+ this.iframe = document.querySelector(selector);
39
+ }
40
+ play() {
41
+ this.iframe.contentWindow?.postMessage('play', '*');
42
+ }
43
+ pause() {
44
+ this.iframe.contentWindow?.postMessage('pause', '*');
45
+ }
46
+ }
47
+ return JetstreamPlayer;
35
48
  };
49
+ export const JetstreamPlayer = initPlayerMethods();
36
50
  document.addEventListener('DOMContentLoaded', initPlayerMethods);
37
- export const embedPlayer = new Proxy({
38
- play: (index) => { },
39
- pause: (index) => { }
40
- }, {
41
- get(target, prop) {
42
- return (index) => {
43
- const method = prop.toString();
44
- iframesWithEmbedVideo[index].contentWindow?.postMessage(method, '*');
45
- };
46
- }
47
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hopecloud/jetstream-player",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Embeddable player for Jetstream videos",
5
5
  "scripts": {
6
6
  "build": "tsc"