@vouchfor/embeds 0.0.0-experiment.146014a → 0.0.0-experiment.14fd0e7

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/embeds",
3
- "version": "0.0.0-experiment.146014a",
3
+ "version": "0.0.0-experiment.14fd0e7",
4
4
  "license": "MIT",
5
5
  "author": "Aaron Williams",
6
6
  "main": "dist/es/embeds.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@lit/task": "^1.0.0",
39
- "@vouchfor/media-player": "0.0.0-experiment.146014a",
39
+ "@vouchfor/media-player": "0.0.0-experiment.14fd0e7",
40
40
  "uuid": "^9.0.1"
41
41
  },
42
42
  "peerDependencies": {
@@ -242,19 +242,30 @@ class TrackingController implements ReactiveController {
242
242
  delete this._streamLatestTime[key];
243
243
  };
244
244
 
245
+ private _pageUnloading = () => {
246
+ this._streamEnded();
247
+ // This will try to send the same stream event again so we delete the start and latest
248
+ // time in stream ended so that there is no times to send and the pause event does nothing
249
+ this.host.pause();
250
+ };
251
+
245
252
  private _handleVisibilityChange = () => {
246
253
  if (document.visibilityState === 'hidden') {
247
- this._streamEnded();
248
-
249
- // This will try to send the same stream event again so we delete the start and latest
250
- // time in stream ended so that there is no times to send and the pause event does nothing
251
- this.host.pause();
254
+ this._pageUnloading();
252
255
  }
253
256
  };
254
257
 
258
+ private _handlePageHide = () => {
259
+ this._pageUnloading();
260
+ };
261
+
255
262
  hostConnected() {
256
263
  requestAnimationFrame(() => {
257
- document.addEventListener('visibilitychange', this._handleVisibilityChange);
264
+ if ('onvisibilitychange' in document) {
265
+ document.addEventListener('visibilitychange', this._handleVisibilityChange);
266
+ } else {
267
+ window.addEventListener('pagehide', this._handlePageHide);
268
+ }
258
269
  this.host.addEventListener('vouch:loaded', this._handleVouchLoaded);
259
270
  this.host.mediaPlayer?.addEventListener('play', this._handlePlay);
260
271
  this.host.mediaPlayer?.addEventListener('video:play', this._handleVideoPlay);
@@ -265,7 +276,11 @@ class TrackingController implements ReactiveController {
265
276
 
266
277
  hostDisconnected() {
267
278
  this._streamEnded();
268
- document.removeEventListener('visibilitychange', this._handleVisibilityChange);
279
+ if ('onvisibilitychange' in document) {
280
+ document.removeEventListener('visibilitychange', this._handleVisibilityChange);
281
+ } else {
282
+ window.removeEventListener('pagehide', this._handlePageHide);
283
+ }
269
284
  this.host.removeEventListener('vouch:loaded', this._handleVouchLoaded);
270
285
  this.host.mediaPlayer?.removeEventListener('play', this._handlePlay);
271
286
  this.host.mediaPlayer?.removeEventListener('video:play', this._handleVideoPlay);
@@ -3,7 +3,7 @@ import { customElement, property, state } from 'lit/decorators.js';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { createRef, ref } from 'lit/directives/ref.js';
5
5
 
6
- import type { Scene, TemplateInstance } from '@vouchfor/canvas-video';
6
+ import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
7
7
  import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
8
8
  import type { Ref } from 'lit/directives/ref.js';
9
9
  import type { Environment } from '~/utils/env';
@@ -149,6 +149,10 @@ class Embed extends LitElement {
149
149
  return this._mediaPlayerRef.value?.scenes ?? [];
150
150
  }
151
151
 
152
+ get sceneConfig(): Scenes | null {
153
+ return this._mediaPlayerRef.value?.sceneConfig ?? null;
154
+ }
155
+
152
156
  get videoState() {
153
157
  return this._mediaPlayerRef.value?.videoState;
154
158
  }