浏览代码

Update scripts

customisations
alemart 1年前
父节点
当前提交
fb5e49d71f
共有 3 个文件被更改,包括 45 次插入28 次删除
  1. 40
    23
      dist/martins.js
  2. 3
    3
      dist/martins.min.js
  3. 2
    2
      package-lock.json

+ 40
- 23
dist/martins.js 查看文件

5
  * https://github.com/alemart/martins-js
5
  * https://github.com/alemart/martins-js
6
  *
6
  *
7
  * @license LGPL-3.0-or-later
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
 (function webpackUniversalModuleDefinition(root, factory) {
10
 (function webpackUniversalModuleDefinition(root, factory) {
11
 	if(typeof exports === 'object' && typeof module === 'object')
11
 	if(typeof exports === 'object' && typeof module === 'object')
30
  * https://github.com/alemart/speedy-vision
30
  * https://github.com/alemart/speedy-vision
31
  *
31
  *
32
  * @license Apache-2.0
32
  * @license Apache-2.0
33
- * Date: 2024-07-02T20:26:01.993Z
33
+ * Date: 2024-07-03T02:16:25.769Z
34
  */
34
  */
35
 (function webpackUniversalModuleDefinition(root, factory) {
35
 (function webpackUniversalModuleDefinition(root, factory) {
36
 	if(true)
36
 	if(true)
9087
    */
9087
    */
9088
   _load(video) {
9088
   _load(video) {
9089
     if (this.isLoaded()) this.release();
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
         this._data = video;
9094
         this._data = video;
9094
         return this;
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
    * @param {HTMLVideoElement} video
9111
    * @param {HTMLVideoElement} video
9111
    * @returns {SpeedyPromise<void>} gets rejected if we can't autoplay
9112
    * @returns {SpeedyPromise<void>} gets rejected if we can't autoplay
9112
    */
9113
    */
9113
-  _handleAutoplay(video) {
9114
+  static _handleAutoplay(video) {
9114
     // Autoplay guide: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
9115
     // Autoplay guide: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
9115
     // Chrome policy: https://developer.chrome.com/blog/autoplay/
9116
     // Chrome policy: https://developer.chrome.com/blog/autoplay/
9116
     // WebKit policy: https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
9117
     // WebKit policy: https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
9137
   }
9138
   }
9138
 
9139
 
9139
   /**
9140
   /**
9140
-   * Load the underlying media
9141
+   * Wait for the input video to be playable
9141
    * @param {HTMLVideoElement} video
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
     /**
25443
     /**
25428
      * Wait for the input video to be playable
25444
      * Wait for the input video to be playable
25429
      * @param video
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
     _waitUntilPlayable(video) {
25448
     _waitUntilPlayable(video) {
25433
         const TIMEOUT = 15000, INTERVAL = 500;
25449
         const TIMEOUT = 15000, INTERVAL = 500;
25434
-        if (video.readyState >= 4)
25450
+        if (video.readyState >= 3)
25435
             return speedy_vision_default().Promise.resolve(video);
25451
             return speedy_vision_default().Promise.resolve(video);
25436
         return new (speedy_vision_default()).Promise((resolve, reject) => {
25452
         return new (speedy_vision_default()).Promise((resolve, reject) => {
25437
             let ms = 0, t = setInterval(() => {
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
                     clearInterval(t);
25456
                     clearInterval(t);
25440
                     resolve(video);
25457
                     resolve(video);
25441
                 }
25458
                 }

+ 3
- 3
dist/martins.min.js
文件差异内容过多而无法显示
查看文件


+ 2
- 2
package-lock.json 查看文件

3066
     },
3066
     },
3067
     "node_modules/speedy-vision": {
3067
     "node_modules/speedy-vision": {
3068
       "version": "0.9.1",
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
       "funding": {
3070
       "funding": {
3071
         "url": "https://github.com/sponsors/alemart"
3071
         "url": "https://github.com/sponsors/alemart"
3072
       }
3072
       }
6116
       }
6116
       }
6117
     },
6117
     },
6118
     "speedy-vision": {
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
       "from": "speedy-vision@github:alemart/speedy-vision#v0.9.1"
6120
       "from": "speedy-vision@github:alemart/speedy-vision#v0.9.1"
6121
     },
6121
     },
6122
     "statuses": {
6122
     "statuses": {

正在加载...
取消
保存