shaka-video-element 0.0.6 → 0.6.2
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 +37 -29
- package/dist/react.d.ts +4 -0
- package/dist/react.js +85 -0
- package/dist/shaka-video-element.js +28095 -25
- package/package.json +32 -29
- package/shaka-video-element.js +87 -0
- package/LICENSE +0 -19
- package/index.html +0 -38
package/package.json
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaka-video-element",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Custom element (web component) for Shaka Player",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"author": "@muxinc",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/muxinc/media-elements#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/muxinc/media-elements/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/muxinc/media-elements.git",
|
|
14
|
+
"directory": "packages/shaka-video-element"
|
|
15
|
+
},
|
|
7
16
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"README.md",
|
|
10
|
-
"index.html"
|
|
17
|
+
"dist"
|
|
11
18
|
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "shaka-video-element.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./shaka-video-element.js",
|
|
23
|
+
"./react": "./dist/react.js"
|
|
24
|
+
},
|
|
12
25
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
26
|
+
"lint": "eslint *.js",
|
|
27
|
+
"serve": "wet serve --cors --livereload",
|
|
28
|
+
"build:react": "build-react-wrapper",
|
|
29
|
+
"build:esm": "esbuild --bundle --format=esm --outfile=dist/shaka-video-element.js shaka-video-element.js",
|
|
30
|
+
"build": "run-s build:*"
|
|
16
31
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"custom-media-element": "^1.3.1",
|
|
34
|
+
"shaka-player": "^4.8.4"
|
|
20
35
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"build-react-wrapper": "^0.1.3",
|
|
38
|
+
"npm-run-all": "^4.1.5",
|
|
39
|
+
"wet-run": "^1.2.2"
|
|
23
40
|
},
|
|
24
41
|
"keywords": [
|
|
25
42
|
"shaka",
|
|
26
43
|
"video",
|
|
27
44
|
"player"
|
|
28
|
-
]
|
|
29
|
-
"author": "@muxinc",
|
|
30
|
-
"license": "MIT",
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"custom-video-element": "^0.0.2",
|
|
33
|
-
"shaka-player": "^4.2.2"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@rollup/plugin-commonjs": "^11.0.2",
|
|
37
|
-
"@rollup/plugin-node-resolve": "^7.1.1",
|
|
38
|
-
"np": "^6.2.0",
|
|
39
|
-
"rollup": "^2.2.0",
|
|
40
|
-
"rollup-plugin-babel-minify": "^10.0.0",
|
|
41
|
-
"rollup-plugin-terser": "^5.3.0"
|
|
42
|
-
}
|
|
45
|
+
]
|
|
43
46
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CustomVideoElement } from 'custom-media-element';
|
|
2
|
+
import shaka from 'shaka-player';
|
|
3
|
+
|
|
4
|
+
function onErrorEvent(event) {
|
|
5
|
+
// Extract the shaka.util.Error object from the event.
|
|
6
|
+
onError(event.detail);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function onError(error) {
|
|
10
|
+
// Log the error.
|
|
11
|
+
console.error('Error code', error.code, 'object', error);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ShakaVideoElement extends CustomVideoElement {
|
|
15
|
+
static shadowRootOptions = { ...CustomVideoElement.shadowRootOptions };
|
|
16
|
+
|
|
17
|
+
static getTemplateHTML = (attrs) => {
|
|
18
|
+
const { src, ...rest } = attrs; // eslint-disable-line no-unused-vars
|
|
19
|
+
return CustomVideoElement.getTemplateHTML(rest);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
if (shaka.Player.isBrowserSupported()) {
|
|
26
|
+
this.api = new shaka.Player();
|
|
27
|
+
// Listen for error events.
|
|
28
|
+
this.api.addEventListener('error', onErrorEvent);
|
|
29
|
+
} else {
|
|
30
|
+
// This browser does not have the minimum set of APIs we need.
|
|
31
|
+
console.error('Browser does not support Shaka Player');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
36
|
+
if (attrName !== 'src') {
|
|
37
|
+
super.attributeChangedCallback(attrName, oldValue, newValue);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (attrName === 'src' && oldValue != newValue) {
|
|
41
|
+
this.load();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get src() {
|
|
46
|
+
// Use the attribute value as the source of truth.
|
|
47
|
+
// No need to store it in two places.
|
|
48
|
+
// This avoids needing a to read the attribute initially and update the src.
|
|
49
|
+
return this.getAttribute('src');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
set src(val) {
|
|
53
|
+
// If being set by attributeChangedCallback,
|
|
54
|
+
// dont' cause an infinite loop
|
|
55
|
+
if (val !== this.src) {
|
|
56
|
+
this.setAttribute('src', val);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async load() {
|
|
61
|
+
if (!this.api) return;
|
|
62
|
+
|
|
63
|
+
// Wait 1 tick to allow other attributes to be set.
|
|
64
|
+
await Promise.resolve();
|
|
65
|
+
|
|
66
|
+
await this.api.attach(this.nativeEl);
|
|
67
|
+
|
|
68
|
+
if (!this.src) {
|
|
69
|
+
this.api.unload();
|
|
70
|
+
} else {
|
|
71
|
+
// Try to load a manifest.
|
|
72
|
+
// This is an asynchronous process.
|
|
73
|
+
try {
|
|
74
|
+
await this.api.load(this.src);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
// onError is executed if the asynchronous load fails.
|
|
77
|
+
onError(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (globalThis.customElements && !globalThis.customElements.get('shaka-video')) {
|
|
84
|
+
globalThis.customElements.define('shaka-video', ShakaVideoElement);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default ShakaVideoElement;
|
package/LICENSE
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2022 Mux, Inc.
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
SOFTWARE.
|
package/index.html
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" dir="ltr">
|
|
3
|
-
<head>
|
|
4
|
-
<title>Shaka [Player] Video Element</title>
|
|
5
|
-
<script type="module" src="https://unpkg.com/media-chrome@0.7"></script>
|
|
6
|
-
<script type="module" src="./dist/shaka-video-element.js"></script>
|
|
7
|
-
|
|
8
|
-
<style>
|
|
9
|
-
media-controller {
|
|
10
|
-
width: 640px;
|
|
11
|
-
height: 360px;
|
|
12
|
-
}
|
|
13
|
-
</style>
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
|
|
17
|
-
<!-- Using media chrome for controls -->
|
|
18
|
-
<media-controller>
|
|
19
|
-
|
|
20
|
-
<shaka-video
|
|
21
|
-
slot="media"
|
|
22
|
-
src="https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8"
|
|
23
|
-
>
|
|
24
|
-
<track label="thumbnails" id="customTrack" default kind="metadata" src="https://image.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/storyboard.vtt"></track>
|
|
25
|
-
</shaka-video>
|
|
26
|
-
<media-control-bar>
|
|
27
|
-
<media-play-button></media-play-button>
|
|
28
|
-
<media-mute-button></media-mute-button>
|
|
29
|
-
<media-volume-range></media-volume-range>
|
|
30
|
-
<media-time-range></media-time-range>
|
|
31
|
-
<media-pip-button></media-pip-button>
|
|
32
|
-
<media-fullscreen-button></media-fullscreen-button>
|
|
33
|
-
</media-control-bar>
|
|
34
|
-
</media-controller>
|
|
35
|
-
|
|
36
|
-
<p><a href="https://github.com/muxinc/shaka-video-element">github.com/muxinc/shaka-video-element</a></p>
|
|
37
|
-
</body>
|
|
38
|
-
</html>
|