Browse Source

Update scripts

customisations
alemart 1 year ago
parent
commit
52fb5b00ac
2 changed files with 45 additions and 10 deletions
  1. 42
    7
      dist/martins.js
  2. 3
    3
      dist/martins.min.js

+ 42
- 7
dist/martins.js View File

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-01T00:42:52.044Z
8
+ * Date: 2024-07-02T20:36:32.182Z
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-01T00:06:27.125Z
33
+ * Date: 2024-07-02T20:26:01.993Z
34
  */
34
  */
35
 (function webpackUniversalModuleDefinition(root, factory) {
35
 (function webpackUniversalModuleDefinition(root, factory) {
36
 	if(true)
36
 	if(true)
9089
     if (this.isLoaded()) this.release();
9089
     if (this.isLoaded()) this.release();
9090
     if (video.readyState >= 4) {
9090
     if (video.readyState >= 4) {
9091
       // already loaded?
9091
       // already loaded?
9092
-      return new speedy_promise/* SpeedyPromise */.i(resolve => {
9092
+      return this._handleAutoplay(video).then(() => {
9093
         this._data = video;
9093
         this._data = video;
9094
-        resolve(this);
9094
+        return this;
9095
       });
9095
       });
9096
     } else {
9096
     } else {
9097
       // waitUntil('canplay'); // use readyState >= 3
9097
       // waitUntil('canplay'); // use readyState >= 3
9098
       setTimeout(() => video.load());
9098
       setTimeout(() => video.load());
9099
       return SpeedyMediaSource._waitUntil(video, 'canplaythrough').then(() => {
9099
       return SpeedyMediaSource._waitUntil(video, 'canplaythrough').then(() => {
9100
-        this._data = video;
9101
-        return this;
9100
+        return this._handleAutoplay(video).then(() => {
9101
+          this._data = video;
9102
+          return this;
9103
+        });
9102
       });
9104
       });
9103
     }
9105
     }
9104
   }
9106
   }
9105
 
9107
 
9106
   /**
9108
   /**
9109
+   * Handle browser quirks concerning autoplay
9110
+   * @param {HTMLVideoElement} video
9111
+   * @returns {SpeedyPromise<void>} gets rejected if we can't autoplay
9112
+   */
9113
+  _handleAutoplay(video) {
9114
+    // Autoplay guide: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
9115
+    // Chrome policy: https://developer.chrome.com/blog/autoplay/
9116
+    // WebKit policy: https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
9117
+
9118
+    // videos marked as autoplay may not play if not visible on-screen
9119
+    // videos marked as autoplay should be muted
9120
+    if (video.autoplay /*&& video.muted*/) {
9121
+      return new speedy_promise/* SpeedyPromise */.i((resolve, reject) => {
9122
+        const promise = video.play();
9123
+
9124
+        // handle older browsers
9125
+        if (promise === undefined) {
9126
+          resolve();
9127
+          return;
9128
+        }
9129
+
9130
+        // wrap promise
9131
+        promise.then(resolve, reject);
9132
+      });
9133
+    }
9134
+
9135
+    // nothing to do
9136
+    return speedy_promise/* SpeedyPromise */.i.resolve();
9137
+  }
9138
+
9139
+  /**
9107
    * Load the underlying media
9140
    * Load the underlying media
9108
    * @param {HTMLVideoElement} video
9141
    * @param {HTMLVideoElement} video
9109
    * @returns {SpeedyPromise<SpeedyMediaSource>}
9142
    * @returns {SpeedyPromise<SpeedyMediaSource>}
25310
                 if (video.hidden) {
25343
                 if (video.hidden) {
25311
                     video.hidden = false;
25344
                     video.hidden = false;
25312
                     video.style.setProperty('opacity', '0');
25345
                     video.style.setProperty('opacity', '0');
25313
-                    video.style.setProperty('position', 'absolute');
25346
+                    video.style.setProperty('position', 'fixed'); // make sure that it's visible on-screen
25347
+                    video.style.setProperty('left', '0');
25348
+                    video.style.setProperty('top', '0');
25314
                     //video.style.setProperty('display', 'none'); // doesn't work. Same as video.hidden
25349
                     //video.style.setProperty('display', 'none'); // doesn't work. Same as video.hidden
25315
                     //video.style.setProperty('visibility', 'hidden'); // doesn't work either
25350
                     //video.style.setProperty('visibility', 'hidden'); // doesn't work either
25316
                 }
25351
                 }

+ 3
- 3
dist/martins.min.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save