Selaa lähdekoodia

Update scripts

customisations
alemart 1 vuosi sitten
vanhempi
commit
fb5e49d71f
3 muutettua tiedostoa jossa 45 lisäystä ja 28 poistoa
  1. 40
    23
      dist/martins.js
  2. 3
    3
      dist/martins.min.js
  3. 2
    2
      package-lock.json

+ 40
- 23
dist/martins.js Näytä tiedosto

@@ -5,7 +5,7 @@
5 5
  * https://github.com/alemart/martins-js
6 6
  *
7 7
  * @license LGPL-3.0-or-later
8
- * Date: 2024-07-02T20:36:32.182Z
8
+ * Date: 2024-07-03T02:20:15.988Z
9 9
  */
10 10
 (function webpackUniversalModuleDefinition(root, factory) {
11 11
 	if(typeof exports === 'object' && typeof module === 'object')
@@ -30,7 +30,7 @@ return /******/ (() => { // webpackBootstrap
30 30
  * https://github.com/alemart/speedy-vision
31 31
  *
32 32
  * @license Apache-2.0
33
- * Date: 2024-07-02T20:26:01.993Z
33
+ * Date: 2024-07-03T02:16:25.769Z
34 34
  */
35 35
 (function webpackUniversalModuleDefinition(root, factory) {
36 36
 	if(true)
@@ -9087,22 +9087,23 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource {
9087 9087
    */
9088 9088
   _load(video) {
9089 9089
     if (this.isLoaded()) this.release();
9090
-    if (video.readyState >= 4) {
9091
-      // already loaded?
9092
-      return this._handleAutoplay(video).then(() => {
9090
+    utils/* Utils */.A.log('Loading a video...');
9091
+    video.load();
9092
+    return SpeedyVideoMediaSource._waitUntilPlayable(video).then(() => {
9093
+      return SpeedyVideoMediaSource._handleAutoplay(video).then(() => {
9093 9094
         this._data = video;
9094 9095
         return this;
9095 9096
       });
9096
-    } else {
9097
-      // waitUntil('canplay'); // use readyState >= 3
9098
-      setTimeout(() => video.load());
9099
-      return SpeedyMediaSource._waitUntil(video, 'canplaythrough').then(() => {
9100
-        return this._handleAutoplay(video).then(() => {
9101
-          this._data = video;
9102
-          return this;
9103
-        });
9104
-      });
9105
-    }
9097
+    });
9098
+  }
9099
+
9100
+  /**
9101
+   * Load the underlying media
9102
+   * @param {HTMLVideoElement} video
9103
+   * @returns {SpeedyPromise<SpeedyMediaSource>}
9104
+   */
9105
+  static load(video) {
9106
+    return new SpeedyVideoMediaSource(PRIVATE_TOKEN)._load(video);
9106 9107
   }
9107 9108
 
9108 9109
   /**
@@ -9110,7 +9111,7 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource {
9110 9111
    * @param {HTMLVideoElement} video
9111 9112
    * @returns {SpeedyPromise<void>} gets rejected if we can't autoplay
9112 9113
    */
9113
-  _handleAutoplay(video) {
9114
+  static _handleAutoplay(video) {
9114 9115
     // Autoplay guide: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
9115 9116
     // Chrome policy: https://developer.chrome.com/blog/autoplay/
9116 9117
     // WebKit policy: https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
@@ -9137,12 +9138,27 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource {
9137 9138
   }
9138 9139
 
9139 9140
   /**
9140
-   * Load the underlying media
9141
+   * Wait for the input video to be playable
9141 9142
    * @param {HTMLVideoElement} video
9142
-   * @returns {SpeedyPromise<SpeedyMediaSource>}
9143
+   * @returns {SpeedyPromise<HTMLVideoElement>} resolves to the input video when it can be played
9143 9144
    */
9144
-  static load(video) {
9145
-    return new SpeedyVideoMediaSource(PRIVATE_TOKEN)._load(video);
9145
+  static _waitUntilPlayable(video) {
9146
+    const TIMEOUT = 30000,
9147
+      INTERVAL = 500;
9148
+    if (video.readyState >= 3) return speedy_promise/* SpeedyPromise */.i.resolve(video);
9149
+    return new speedy_promise/* SpeedyPromise */.i((resolve, reject) => {
9150
+      let ms = 0,
9151
+        t = setInterval(() => {
9152
+          //if(video.readyState >= 4) { // canplaythrough (may timeout on slow connections)
9153
+          if (video.readyState >= 3) {
9154
+            clearInterval(t);
9155
+            resolve(video);
9156
+          } else if ((ms += INTERVAL) >= TIMEOUT) {
9157
+            clearInterval(t);
9158
+            reject(new utils_errors/* TimeoutError */.MU('The video took too long to load'));
9159
+          }
9160
+        }, INTERVAL);
9161
+    });
9146 9162
   }
9147 9163
 }
9148 9164
 
@@ -25427,15 +25443,16 @@ class VideoSource {
25427 25443
     /**
25428 25444
      * Wait for the input video to be playable
25429 25445
      * @param video
25430
-     * @returns a promise that resolves to the input video when it can be played through to the end
25446
+     * @returns a promise that resolves to the input video when it can be played
25431 25447
      */
25432 25448
     _waitUntilPlayable(video) {
25433 25449
         const TIMEOUT = 15000, INTERVAL = 500;
25434
-        if (video.readyState >= 4)
25450
+        if (video.readyState >= 3)
25435 25451
             return speedy_vision_default().Promise.resolve(video);
25436 25452
         return new (speedy_vision_default()).Promise((resolve, reject) => {
25437 25453
             let ms = 0, t = setInterval(() => {
25438
-                if (video.readyState >= 4) { // canplaythrough
25454
+                //if(video.readyState >= 4) { // canplaythrough (may timeout on slow connections)
25455
+                if (video.readyState >= 3) {
25439 25456
                     clearInterval(t);
25440 25457
                     resolve(video);
25441 25458
                 }

+ 3
- 3
dist/martins.min.js
File diff suppressed because it is too large
Näytä tiedosto


+ 2
- 2
package-lock.json Näytä tiedosto

@@ -3066,7 +3066,7 @@
3066 3066
     },
3067 3067
     "node_modules/speedy-vision": {
3068 3068
       "version": "0.9.1",
3069
-      "resolved": "git+ssh://git@github.com/alemart/speedy-vision.git#0413026c238312352aee262bd0ab884116712449",
3069
+      "resolved": "git+ssh://git@github.com/alemart/speedy-vision.git#6a48fca4c45b6f4c80bfa8bcacbed5abd0e69ec2",
3070 3070
       "funding": {
3071 3071
         "url": "https://github.com/sponsors/alemart"
3072 3072
       }
@@ -6116,7 +6116,7 @@
6116 6116
       }
6117 6117
     },
6118 6118
     "speedy-vision": {
6119
-      "version": "git+ssh://git@github.com/alemart/speedy-vision.git#0413026c238312352aee262bd0ab884116712449",
6119
+      "version": "git+ssh://git@github.com/alemart/speedy-vision.git#6a48fca4c45b6f4c80bfa8bcacbed5abd0e69ec2",
6120 6120
       "from": "speedy-vision@github:alemart/speedy-vision#v0.9.1"
6121 6121
     },
6122 6122
     "statuses": {

Loading…
Peruuta
Tallenna