Преглед изворни кода

Update scripts

customisations
alemart пре 1 година
родитељ
комит
52fb5b00ac
2 измењених фајлова са 45 додато и 10 уклоњено
  1. 42
    7
      dist/martins.js
  2. 3
    3
      dist/martins.min.js

+ 42
- 7
dist/martins.js Прегледај датотеку

@@ -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-01T00:42:52.044Z
8
+ * Date: 2024-07-02T20:36:32.182Z
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-01T00:06:27.125Z
33
+ * Date: 2024-07-02T20:26:01.993Z
34 34
  */
35 35
 (function webpackUniversalModuleDefinition(root, factory) {
36 36
 	if(true)
@@ -9089,21 +9089,54 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource {
9089 9089
     if (this.isLoaded()) this.release();
9090 9090
     if (video.readyState >= 4) {
9091 9091
       // already loaded?
9092
-      return new speedy_promise/* SpeedyPromise */.i(resolve => {
9092
+      return this._handleAutoplay(video).then(() => {
9093 9093
         this._data = video;
9094
-        resolve(this);
9094
+        return this;
9095 9095
       });
9096 9096
     } else {
9097 9097
       // waitUntil('canplay'); // use readyState >= 3
9098 9098
       setTimeout(() => video.load());
9099 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 9140
    * Load the underlying media
9108 9141
    * @param {HTMLVideoElement} video
9109 9142
    * @returns {SpeedyPromise<SpeedyMediaSource>}
@@ -25310,7 +25343,9 @@ class VideoSource {
25310 25343
                 if (video.hidden) {
25311 25344
                     video.hidden = false;
25312 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 25349
                     //video.style.setProperty('display', 'none'); // doesn't work. Same as video.hidden
25315 25350
                     //video.style.setProperty('visibility', 'hidden'); // doesn't work either
25316 25351
                 }

+ 3
- 3
dist/martins.min.js
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


Loading…
Откажи
Сачувај