@zcomponent/three-video-player 1.1.3 → 1.1.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.
|
@@ -56,6 +56,7 @@ export declare abstract class BaseVideo extends Object3D implements Stream {
|
|
|
56
56
|
protected _gain: GainNode;
|
|
57
57
|
protected _hadUserEvent: boolean;
|
|
58
58
|
constructor(ctx: ContextManager, constructorProps: BaseVideoConstructorProps);
|
|
59
|
+
private _updateSize;
|
|
59
60
|
private _updateMute;
|
|
60
61
|
/**
|
|
61
62
|
* The volume of the video, from 0 to 1.
|
|
@@ -33,6 +33,15 @@ export class BaseVideo extends Object3D {
|
|
|
33
33
|
this.onWaiting = new Event();
|
|
34
34
|
this.onError = new Event();
|
|
35
35
|
this._hadUserEvent = false;
|
|
36
|
+
this._updateSize = () => {
|
|
37
|
+
if (this.videoElement.videoHeight === 0)
|
|
38
|
+
return;
|
|
39
|
+
let transparencyAspectFix = 1;
|
|
40
|
+
if (this.transparent === VideoTransparencyType.sideBySide) {
|
|
41
|
+
transparencyAspectFix = this.direction.value === SideBySideDirection.LeftRight ? 0.5 : 2;
|
|
42
|
+
}
|
|
43
|
+
this.mesh.scale.set((transparencyAspectFix * this.videoElement.videoWidth) / this.videoElement.videoHeight, 1, 1);
|
|
44
|
+
};
|
|
36
45
|
this._updateMute = () => {
|
|
37
46
|
if (!this.videoElement || !this._hadUserEvent)
|
|
38
47
|
return;
|
|
@@ -119,6 +128,7 @@ export class BaseVideo extends Object3D {
|
|
|
119
128
|
this.geometry = constructorProps.geometry ?? new THREE.PlaneGeometry();
|
|
120
129
|
registerLoadable(ctx, new Promise((resolve, reject) => {
|
|
121
130
|
videoElement.addEventListener('canplaythrough', () => {
|
|
131
|
+
this._updateSize();
|
|
122
132
|
resolve();
|
|
123
133
|
});
|
|
124
134
|
videoElement.addEventListener('error', err => {
|
|
@@ -158,13 +168,8 @@ export class BaseVideo extends Object3D {
|
|
|
158
168
|
}
|
|
159
169
|
this.mesh = new THREE.Mesh(this.geometry, this.material);
|
|
160
170
|
this.element.add(this.mesh);
|
|
161
|
-
this.videoElement.addEventListener('
|
|
162
|
-
|
|
163
|
-
if (this.transparent === VideoTransparencyType.sideBySide) {
|
|
164
|
-
transparencyAspectFix = this.direction.value === SideBySideDirection.LeftRight ? 0.5 : 2;
|
|
165
|
-
}
|
|
166
|
-
this.mesh.scale.set((transparencyAspectFix * this.videoElement.videoWidth) / this.videoElement.videoHeight, 1, 1);
|
|
167
|
-
});
|
|
171
|
+
this.videoElement.addEventListener('loadeddata', this._updateSize);
|
|
172
|
+
this.videoElement.addEventListener('loadedmetadata', this._updateSize);
|
|
168
173
|
this.register(this.muted, this._updateMute);
|
|
169
174
|
nextUserEvent(ctx).then(() => {
|
|
170
175
|
this._hadUserEvent = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextManager } from '@zcomponent/core';
|
|
2
|
-
import { BaseVideo, BaseVideoConstructorProps } from '
|
|
2
|
+
import { BaseVideo, BaseVideoConstructorProps } from '../index';
|
|
3
3
|
export interface VideoConstructorProps extends BaseVideoConstructorProps {
|
|
4
4
|
/** @zprop
|
|
5
5
|
* @zvalues files *.m3u8, *.mp4
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// TODO- import type and dynamic import later
|
|
2
2
|
import Hls from 'hls.js';
|
|
3
|
-
import {
|
|
3
|
+
import { registerLoadable } from '@zcomponent/core';
|
|
4
|
+
import { BaseVideo } from '../index';
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
* Manages the playback and display of a video in a 3D environment.
|
|
@@ -22,10 +23,13 @@ export class VideoPlayer extends BaseVideo {
|
|
|
22
23
|
super(ctx, constructorProps);
|
|
23
24
|
this.constructorProps = constructorProps;
|
|
24
25
|
this.hls = null;
|
|
26
|
+
registerLoadable(this.contextManager, this.load());
|
|
25
27
|
}
|
|
26
28
|
async load() {
|
|
27
29
|
const isHls = this.constructorProps.source.endsWith('.m3u8');
|
|
28
|
-
|
|
30
|
+
if (isHls && !this.videoElement.canPlayType('application/vnd.apple.mpegurl'))
|
|
31
|
+
return this._loadHlsVideo();
|
|
32
|
+
return this._loadMp4Video();
|
|
29
33
|
}
|
|
30
34
|
async _loadHlsVideo() {
|
|
31
35
|
if (!Hls.isSupported()) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zcomponent/three-video-player",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "HLS & MP4 Player for Mattercraft",
|
|
5
5
|
"author": "Zappar Limited",
|
|
6
6
|
"license": "Proprietary",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"public/**/*"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "rm -rf lib && tsc",
|
|
22
|
+
"build": "rm -rf lib && tsc && tsc-alias",
|
|
23
23
|
"watch": "tsc -w",
|
|
24
24
|
"prepack": "npm run build",
|
|
25
25
|
"docs": "typedoc --out docs"
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"hls.js": "^1.5.12"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@zcomponent/three": "1.26.
|
|
32
|
-
"three": "^0.150.1"
|
|
31
|
+
"@zcomponent/three": "^1.26.2"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"@zcomponent/three": "1.x",
|
|
@@ -55,16 +54,7 @@
|
|
|
55
54
|
],
|
|
56
55
|
"plugins": [
|
|
57
56
|
"@semantic-release/commit-analyzer",
|
|
58
|
-
|
|
59
|
-
"@semantic-release/release-notes-generator",
|
|
60
|
-
{
|
|
61
|
-
"writerOpts": {
|
|
62
|
-
"commitUrlFormat": null,
|
|
63
|
-
"issueUrlFormat": null,
|
|
64
|
-
"commitPartial": "* {{#if subject}}{{subject}}{{else}}{{header}}{{/if}}"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
],
|
|
57
|
+
"@semantic-release/release-notes-generator",
|
|
68
58
|
"@semantic-release/changelog",
|
|
69
59
|
"@semantic-release/npm",
|
|
70
60
|
"@semantic-release/gitlab",
|
|
@@ -73,9 +63,9 @@
|
|
|
73
63
|
"@rimac-technology/semantic-release-s3",
|
|
74
64
|
{
|
|
75
65
|
"s3Bucket": {
|
|
76
|
-
"main": "mattercraft-api-docs
|
|
77
|
-
"beta": "mattercraft-api-docs
|
|
78
|
-
"alpha": "mattercraft-api-docs
|
|
66
|
+
"main": "mattercraft-api-docs",
|
|
67
|
+
"beta": "mattercraft-api-docs-beta",
|
|
68
|
+
"alpha": "mattercraft-api-docs-alpha"
|
|
79
69
|
},
|
|
80
70
|
"directoryPath": "../../docs/**/*",
|
|
81
71
|
"objectACL": "",
|