@zcomponent/three-video-player 1.1.4 → 1.1.6

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('loadedmetadata', () => {
162
- let transparencyAspectFix = 1;
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;
@@ -225,6 +230,8 @@ export class BaseVideo extends Object3D {
225
230
  this.videoElement.onplaying = null;
226
231
  this.videoElement.onwaiting = null;
227
232
  this.videoElement.onerror = null;
233
+ this.videoElement.src = '';
234
+ this.videoElement.srcObject = null;
228
235
  return super.dispose();
229
236
  }
230
237
  }
@@ -1,5 +1,5 @@
1
1
  import { ContextManager } from '@zcomponent/core';
2
- import { BaseVideo, BaseVideoConstructorProps } from './basevideo';
2
+ import { BaseVideo, BaseVideoConstructorProps } from '../index';
3
3
  export interface VideoConstructorProps extends BaseVideoConstructorProps {
4
4
  /** @zprop
5
5
  * @zvalues files *.m3u8, *.mp4
@@ -1,7 +1,7 @@
1
1
  // TODO- import type and dynamic import later
2
2
  import Hls from 'hls.js';
3
3
  import { registerLoadable } from '@zcomponent/core';
4
- import { BaseVideo } from './basevideo';
4
+ import { BaseVideo } from '../index';
5
5
  /**
6
6
  *
7
7
  * Manages the playback and display of a video in a 3D environment.
@@ -27,7 +27,9 @@ export class VideoPlayer extends BaseVideo {
27
27
  }
28
28
  async load() {
29
29
  const isHls = this.constructorProps.source.endsWith('.m3u8');
30
- return isHls ? this._loadHlsVideo() : this._loadMp4Video();
30
+ if (isHls && !this.videoElement.canPlayType('application/vnd.apple.mpegurl'))
31
+ return this._loadHlsVideo();
32
+ return this._loadMp4Video();
31
33
  }
32
34
  async _loadHlsVideo() {
33
35
  if (!Hls.isSupported()) {
@@ -90,7 +92,6 @@ export class VideoPlayer extends BaseVideo {
90
92
  this.hls.destroy();
91
93
  this.hls = null;
92
94
  }
93
- this.videoElement.src = '';
94
95
  return super.dispose();
95
96
  }
96
97
  }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { BaseVideo, BaseVideoConstructorProps } from './components/basevideo';
1
2
  export { VideoTransparencyType } from './components/basevideo';
2
3
  export { VideoConstructorProps } from './components/videoplayer';
3
4
  export { VideoPlayer } from './components/videoplayer';
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export { BaseVideo } from './components/basevideo';
1
2
  export { VideoTransparencyType } from './components/basevideo';
2
3
  export { VideoPlayer } from './components/videoplayer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zcomponent/three-video-player",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
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.1-beta",
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",
@@ -74,8 +64,8 @@
74
64
  {
75
65
  "s3Bucket": {
76
66
  "main": "mattercraft-api-docs/prod",
77
- "beta": "mattercraft-api-docs/beta",
78
- "alpha": "mattercraft-api-docs/alpha"
67
+ "beta": "mattercraft-api-docs-beta",
68
+ "alpha": "mattercraft-api-docs-alpha"
79
69
  },
80
70
  "directoryPath": "../../docs/**/*",
81
71
  "objectACL": "",