videoplayer-extension 1.1.0 → 1.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 +63 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,21 +6,78 @@ https://sharkiller.dev/videoplayer/
|
|
|
6
6
|
|
|
7
7
|
https://github.com/sharkiller/Reproductor-MPD-M3U8
|
|
8
8
|
|
|
9
|
+
### How to use
|
|
10
|
+
|
|
11
|
+
https://github.com/sharkiller/Reproductor-MPD-M3U8/wiki/Embed-player
|
|
12
|
+
|
|
9
13
|
### Required
|
|
10
14
|
|
|
11
|
-
⚠️ This validate VideoPlayer Extension
|
|
15
|
+
⚠️ This validate VideoPlayer Extension and get the path of the players on different browsers.
|
|
12
16
|
|
|
13
|
-
## Direct Usage
|
|
17
|
+
## Direct Usage Example
|
|
14
18
|
```html
|
|
19
|
+
<!-- Use unpkg, or you can host the script on your own. -->
|
|
15
20
|
<script src="https://unpkg.com/videoplayer-extension@latest/index.min.js"></script>
|
|
16
21
|
|
|
17
22
|
<script>
|
|
18
23
|
(async () => {
|
|
19
|
-
|
|
24
|
+
// This check if the extension is installed and populate the variables.
|
|
20
25
|
const vp = await VideoPlayer.init();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
// Ask if the extension could be found
|
|
28
|
+
if ( vp.isInstalled() ) {
|
|
29
|
+
// Firefox: moz-extension://{RANDOM-UUID}/pages/player.html
|
|
30
|
+
// Chrome: chrome-extension://opmeopcambhfimffbomjgemehjkbbmji/pages/player.html
|
|
31
|
+
let direct_player_url = vp.getDirectPlayer();
|
|
32
|
+
|
|
33
|
+
// Firefox: moz-extension://{RANDOM-UUID}/iptv/player.html
|
|
34
|
+
// Chrome: chrome-extension://opmeopcambhfimffbomjgemehjkbbmji/iptv/player.html
|
|
35
|
+
let iptv_player_url = vp.getIPTVPlayer();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Your code when the extension is found.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
// Example
|
|
42
|
+
const extension_url = new URL(direct_player_url);
|
|
43
|
+
|
|
44
|
+
const media_url = new URL('https://livesim.dashif.org/livesim2/testpic4_8s/Manifest.mpd');
|
|
45
|
+
media_url.searchParams.set('title', 'Stream Test Example');
|
|
46
|
+
// HTTP Headers example
|
|
47
|
+
media_url.searchParams.set('headers', btoa(JSON.stringify({
|
|
48
|
+
'User-Agent': 'VideoPlayer Extension',
|
|
49
|
+
'referer': 'https://sharkiller.dev/videoplayer/',
|
|
50
|
+
})));
|
|
51
|
+
// ClearKey example
|
|
52
|
+
media_url.searchParams.set('ck', btoa(JSON.stringify({
|
|
53
|
+
"11223344556677889900aabbccddeeff":"11223344556677889900aabbccddeeff",
|
|
54
|
+
"223344556677889900aabbccddeeff11":"223344556677889900aabbccddeeff11",
|
|
55
|
+
"3344556677889900aabbccddeeff1122":"3344556677889900aabbccddeeff1122"
|
|
56
|
+
})));
|
|
57
|
+
|
|
58
|
+
// Or you can assign, to the extension hash, your full media url directly
|
|
59
|
+
extension_url.hash = media_url.href;
|
|
60
|
+
|
|
61
|
+
const iframe = document.querySelector('iframe.example');
|
|
62
|
+
iframe.setAttribute('src', extension_url.href);
|
|
63
|
+
iframe.style.display = 'block';
|
|
64
|
+
|
|
65
|
+
} else {
|
|
66
|
+
// Return https://sharkiller.dev/videoplayer/ to let users install the extension.
|
|
67
|
+
let install_url = VideoPlayer.getInstallUrl();
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Your code when the extension cannot be found.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
// Example
|
|
74
|
+
const div = document.querySelector('div.install');
|
|
75
|
+
div.innerHTML = `Install the extension: <a href="${install_url}" target="_blank">${install_url}</a>`;
|
|
76
|
+
div.style.display = 'block';
|
|
77
|
+
}
|
|
24
78
|
})();
|
|
25
79
|
</script>
|
|
80
|
+
|
|
81
|
+
<div class="install" style="display: none"></div>
|
|
82
|
+
<iframe class="example" allow="encrypted-media *; autoplay" width="1280" height="720" style="display: none"></iframe>
|
|
26
83
|
```
|