@vouchfor/embeds 0.0.0-experiment.a499b59 → 0.0.0-experiment.a63622c

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.a499b59",
3
+ "version": "0.0.0-experiment.a63622c",
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.a499b59",
39
+ "@vouchfor/media-player": "0.0.0-experiment.a63622c",
40
40
  "uuid": "^9.0.1"
41
41
  },
42
42
  "peerDependencies": {
@@ -242,30 +242,19 @@ 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
-
252
245
  private _handleVisibilityChange = () => {
253
246
  if (document.visibilityState === 'hidden') {
254
- this._pageUnloading();
255
- }
256
- };
247
+ this._streamEnded();
257
248
 
258
- private _handlePageHide = () => {
259
- this._pageUnloading();
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();
252
+ }
260
253
  };
261
254
 
262
255
  hostConnected() {
263
256
  requestAnimationFrame(() => {
264
- if ('onvisibilitychange' in document) {
265
- document.addEventListener('visibilitychange', this._handleVisibilityChange);
266
- } else {
267
- window.addEventListener('pagehide', this._handlePageHide);
268
- }
257
+ document.addEventListener('visibilitychange', this._handleVisibilityChange);
269
258
  this.host.addEventListener('vouch:loaded', this._handleVouchLoaded);
270
259
  this.host.mediaPlayer?.addEventListener('play', this._handlePlay);
271
260
  this.host.mediaPlayer?.addEventListener('video:play', this._handleVideoPlay);
@@ -276,11 +265,7 @@ class TrackingController implements ReactiveController {
276
265
 
277
266
  hostDisconnected() {
278
267
  this._streamEnded();
279
- if ('onvisibilitychange' in document) {
280
- document.removeEventListener('visibilitychange', this._handleVisibilityChange);
281
- } else {
282
- window.removeEventListener('pagehide', this._handlePageHide);
283
- }
268
+ document.removeEventListener('visibilitychange', this._handleVisibilityChange);
284
269
  this.host.removeEventListener('vouch:loaded', this._handleVouchLoaded);
285
270
  this.host.mediaPlayer?.removeEventListener('play', this._handlePlay);
286
271
  this.host.mediaPlayer?.removeEventListener('video:play', this._handleVideoPlay);