videoplayer-extension 0.0.1 → 1.0.0

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 CHANGED
@@ -2,7 +2,25 @@
2
2
 
3
3
  A helper library for VideoPlayer Browser Extension
4
4
 
5
- ## Installation
5
+ https://sharkiller.dev/videoplayer/
6
6
 
7
- ```bash
8
- npm install videoplayer-extension
7
+ https://github.com/sharkiller/Reproductor-MPD-M3U8
8
+
9
+ ### Required
10
+
11
+ ⚠️ This validate VideoPlayer Extension installation version > `26.1.5.8388`
12
+
13
+ ## Direct Usage
14
+ ```html
15
+ <script src="https://unpkg.com/videoplayer-extension@latest/index.min.js"></script>
16
+
17
+ <script>
18
+ (async () => {
19
+ console.log('getInstallUrl()? ', VideoPlayer.getInstallUrl());
20
+ const vp = await VideoPlayer.init();
21
+ console.log('isInstalled()? ', vp.isInstalled());
22
+ console.log('getDirectPlayer()? ', vp.getDirectPlayer());
23
+ console.log('getIPTVPlayer()? ', vp.getIPTVPlayer());
24
+ })();
25
+ </script>
26
+ ```
package/index.js CHANGED
@@ -1,22 +1,100 @@
1
- module.exports = {
1
+ /**
2
+ * Check if the VideoPlayer Extension is installed
3
+ * @classDesc Use the static init() method to initialize the class.
4
+ * @author Sharkiller
5
+ * @hideconstructor
6
+ */
7
+ class VideoPlayer {
8
+
9
+ #initialized = false;
10
+ #isInstalled = false;
11
+ #extensionUrl = false;
12
+
13
+ constructor(init) {
14
+ if(init === 'init'){
15
+ this.#initialized = true;
16
+ }else{
17
+ console.warn("Use: const videoplayer = await VideoPlayer.init();");
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Return installation link for the VideoPlayer Extension.
23
+ * @returns {string}
24
+ */
25
+ static getInstallUrl() {
26
+ return 'https://sharkiller.dev/videoplayer/';
27
+ }
28
+
29
+ /**
30
+ * Initializes the VideoPlayer detector.
31
+ * Must be called before using any instance methods.
32
+ * @returns {Promise<VideoPlayer>}
33
+ */
34
+ static async init() {
35
+ const videoplayer = new VideoPlayer('init');
36
+ await videoplayer.checkExtension();
37
+ return videoplayer;
38
+ }
39
+
40
+ async checkExtension() {
41
+ if (!this.#isInitialized()) {
42
+ return;
43
+ }
44
+ try {
45
+ const response = await fetch('isInstalled.mpd', {method: 'HEAD', redirect: 'follow'});
46
+
47
+ if (response.redirected && response.url.endsWith('/pages/player.html') ) {
48
+ const regex = /^(.*\/)pages\/player\.html$/i;
49
+ const result = regex.exec(response.url);
50
+ this.#extensionUrl = result[1];
51
+ this.#isInstalled = true;
52
+ }
53
+ } catch (error) {}
54
+ }
55
+
56
+ #isInitialized() {
57
+ if (!this.#initialized) {
58
+ console.warn("VideoPlayer class not initialized! Use first: const videoplayer = await VideoPlayer.init();");
59
+ }
60
+ return this.#initialized;
61
+ }
62
+
63
+ /**
64
+ * Returns TRUE if the VideoPlayer is installed or FALSE if not.
65
+ * @returns {boolean}
66
+ */
67
+ isInstalled() {
68
+ if (!this.#isInitialized()) {
69
+ return false;
70
+ }
71
+ return this.#isInstalled;
72
+ }
73
+
2
74
  /**
3
- * Is VideoPlayer Browser Extension installed?
4
- * @param {function} installed
5
- * @param {function} uninstalled
75
+ * Return the full extension path to the Direct Player extension.
76
+ * @returns {string|false}
6
77
  */
7
- isInstalled: (installed, uninstalled) => {
8
- console.log(`isInstalled`);
9
- let img = document.createElement('img');
10
- img.onerror = uninstalled;
11
- img.onload = installed;
12
- img.src = 'chrome-extension://opmeopcambhfimffbomjgemehjkbbmji/play-on.png'
13
- },
14
- getDirectPlayer: () => {
15
- console.log('getDirectPlayer');
16
- return 'chrome-extension://opmeopcambhfimffbomjgemehjkbbmji/pages/player.html';
17
- },
18
- getIPTVPlayer: () => {
19
- console.log('getIPTVPlayer');
20
- return 'chrome-extension://opmeopcambhfimffbomjgemehjkbbmji/iptv/player.html';
21
- }
22
- };
78
+ getDirectPlayer() {
79
+ if (!this.#isInitialized() || !this.#isInstalled) {
80
+ console.warn("VideoPlayer extension is not installed! Check isInstalled() first.");
81
+ return false;
82
+ }
83
+ return this.#extensionUrl + 'pages/player.html';
84
+ }
85
+
86
+ /**
87
+ * Return the full extension path to the IPTV Player extension.
88
+ * @returns {string|false}
89
+ */
90
+ getIPTVPlayer() {
91
+ if (!this.#isInitialized() || !this.#isInstalled) {
92
+ console.warn("VideoPlayer extension is not installed! Check isInstalled() first.");
93
+ return false;
94
+ }
95
+ return this.#extensionUrl + 'iptv/player.html';
96
+ }
97
+
98
+ }
99
+
100
+ window.VideoPlayer = VideoPlayer;
package/index.min.js ADDED
@@ -0,0 +1,2 @@
1
+ class VideoPlayer{#i=!1;#t=!1;#e=!1;constructor(i){"init"===i?this.#i=!0:console.warn("Use: const videoplayer = await VideoPlayer.init();")}static getInstallUrl(){return"https://sharkiller.dev/videoplayer/"}static async init(){const i=new VideoPlayer("init");return await i.checkExtension(),i}async checkExtension(){if(this.#s())try{const i=await fetch("isInstalled.mpd",{method:"HEAD",redirect:"follow"});if(i.redirected&&i.url.endsWith("/pages/player.html")){const t=/^(.*\/)pages\/player\.html$/i.exec(i.url);this.#e=t[1],this.#t=!0}}catch(i){}}#s(){return this.#i||console.warn("VideoPlayer class not initialized! Use first: const videoplayer = await VideoPlayer.init();"),this.#i}isInstalled(){return!!this.#s()&&this.#t}getDirectPlayer(){return this.#s()&&this.#t?this.#e+"pages/player.html":(console.warn("VideoPlayer extension is not installed! Check isInstalled() first."),!1)}getIPTVPlayer(){return this.#s()&&this.#t?this.#e+"iptv/player.html":(console.warn("VideoPlayer extension is not installed! Check isInstalled() first."),!1)}}window.VideoPlayer=VideoPlayer;
2
+ //# sourceMappingURL=index.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VideoPlayer","initialized","isInstalled","extensionUrl","constructor","init","this","console","warn","getInstallUrl","videoplayer","checkExtension","isInitialized","response","fetch","method","redirect","redirected","url","endsWith","result","exec","error","getDirectPlayer","getIPTVPlayer","window"],"sources":["index.js"],"sourcesContent":["/**\r\n * Check if the VideoPlayer Extension is installed\r\n * @classDesc Use the static init() method to initialize the class.\r\n * @author Sharkiller\r\n * @hideconstructor\r\n */\r\nclass VideoPlayer {\r\n\r\n #initialized = false;\r\n #isInstalled = false;\r\n #extensionUrl = false;\r\n\r\n constructor(init) {\r\n if(init === 'init'){\r\n this.#initialized = true;\r\n }else{\r\n console.warn(\"Use: const videoplayer = await VideoPlayer.init();\");\r\n }\r\n }\r\n\r\n /**\r\n * Return installation link for the VideoPlayer Extension.\r\n * @returns {string}\r\n */\r\n static getInstallUrl() {\r\n return 'https://sharkiller.dev/videoplayer/';\r\n }\r\n\r\n /**\r\n * Initializes the VideoPlayer detector.\r\n * Must be called before using any instance methods.\r\n * @returns {Promise<VideoPlayer>}\r\n */\r\n static async init() {\r\n const videoplayer = new VideoPlayer('init');\r\n await videoplayer.checkExtension();\r\n return videoplayer;\r\n }\r\n\r\n async checkExtension() {\r\n if (!this.#isInitialized()) {\r\n return;\r\n }\r\n try {\r\n const response = await fetch('isInstalled.mpd', {method: 'HEAD', redirect: 'follow'});\r\n\r\n if (response.redirected && response.url.endsWith('/pages/player.html') ) {\r\n const regex = /^(.*\\/)pages\\/player\\.html$/i;\r\n const result = regex.exec(response.url);\r\n this.#extensionUrl = result[1];\r\n this.#isInstalled = true;\r\n }\r\n } catch (error) {}\r\n }\r\n\r\n #isInitialized() {\r\n if (!this.#initialized) {\r\n console.warn(\"VideoPlayer class not initialized! Use first: const videoplayer = await VideoPlayer.init();\");\r\n }\r\n return this.#initialized;\r\n }\r\n\r\n /**\r\n * Returns TRUE if the VideoPlayer is installed or FALSE if not.\r\n * @returns {boolean}\r\n */\r\n isInstalled() {\r\n if (!this.#isInitialized()) {\r\n return false;\r\n }\r\n return this.#isInstalled;\r\n }\r\n\r\n /**\r\n * Return the full extension path to the Direct Player extension.\r\n * @returns {string|false}\r\n */\r\n getDirectPlayer() {\r\n if (!this.#isInitialized() || !this.#isInstalled) {\r\n console.warn(\"VideoPlayer extension is not installed! Check isInstalled() first.\");\r\n return false;\r\n }\r\n return this.#extensionUrl + 'pages/player.html';\r\n }\r\n\r\n /**\r\n * Return the full extension path to the IPTV Player extension.\r\n * @returns {string|false}\r\n */\r\n getIPTVPlayer() {\r\n if (!this.#isInitialized() || !this.#isInstalled) {\r\n console.warn(\"VideoPlayer extension is not installed! Check isInstalled() first.\");\r\n return false;\r\n }\r\n return this.#extensionUrl + 'iptv/player.html';\r\n }\r\n\r\n}\r\n\r\nwindow.VideoPlayer = VideoPlayer;"],"mappings":"AAMA,MAAMA,YAEFC,IAAe,EACfC,IAAe,EACfC,IAAgB,EAEhB,WAAAC,CAAYC,GACI,SAATA,EACCC,MAAKL,GAAe,EAEpBM,QAAQC,KAAK,qDAErB,CAMA,oBAAOC,GACH,MAAO,qCACX,CAOA,iBAAaJ,GACT,MAAMK,EAAc,IAAIV,YAAY,QAEpC,aADMU,EAAYC,iBACXD,CACX,CAEA,oBAAMC,GACF,GAAKL,MAAKM,IAGV,IACI,MAAMC,QAAiBC,MAAM,kBAAmB,CAACC,OAAQ,OAAQC,SAAU,WAE3E,GAAIH,EAASI,YAAcJ,EAASK,IAAIC,SAAS,sBAAwB,CACrE,MACMC,EADQ,+BACOC,KAAKR,EAASK,KACnCZ,MAAKH,EAAgBiB,EAAO,GAC5Bd,MAAKJ,GAAe,CACxB,CACJ,CAAE,MAAOoB,GAAQ,CACrB,CAEA,EAAAV,GAII,OAHKN,MAAKL,GACNM,QAAQC,KAAK,+FAEVF,MAAKL,CAChB,CAMA,WAAAC,GACI,QAAKI,MAAKM,KAGHN,MAAKJ,CAChB,CAMA,eAAAqB,GACI,OAAKjB,MAAKM,KAAqBN,MAAKJ,EAI7BI,MAAKH,EAAgB,qBAHxBI,QAAQC,KAAK,uEACN,EAGf,CAMA,aAAAgB,GACI,OAAKlB,MAAKM,KAAqBN,MAAKJ,EAI7BI,MAAKH,EAAgB,oBAHxBI,QAAQC,KAAK,uEACN,EAGf,EAIJiB,OAAOzB,YAAcA","ignoreList":[]}
package/package.json CHANGED
@@ -1,9 +1,29 @@
1
1
  {
2
2
  "name": "videoplayer-extension",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "description": "A helper library for VideoPlayer Browser Extension",
5
5
  "main": "index.js",
6
- "keywords": ["video", "player", "extension", "chrome", "firefox", "iptv", "m3u", "mpd", "m3u8"],
6
+ "module": "index.js",
7
+ "unpkg": "index.js",
8
+ "browser": "index.js",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.js",
12
+ "require": "./index.js",
13
+ "default": "./index.js"
14
+ }
15
+ },
16
+ "keywords": [
17
+ "video",
18
+ "player",
19
+ "extension",
20
+ "chrome",
21
+ "firefox",
22
+ "iptv",
23
+ "m3u",
24
+ "mpd",
25
+ "m3u8"
26
+ ],
7
27
  "author": "Sharkiller <support@sharkiller.dev>",
8
28
  "license": "MIT",
9
29
  "repository": {
@@ -14,4 +34,4 @@
14
34
  "url": "https://github.com/sharkiller/videoplayer-extension/issues"
15
35
  },
16
36
  "homepage": "https://github.com/sharkiller/videoplayer-extension#readme"
17
- }
37
+ }