瀏覽代碼

Update VideoSource._handleAutoPlay()

customisations
alemart 1 年之前
父節點
當前提交
dbfdc69c91
共有 1 個檔案被更改,包括 10 行新增1 行删除
  1. 10
    1
      src/sources/video-source.ts

+ 10
- 1
src/sources/video-source.ts 查看文件

@@ -154,6 +154,9 @@ export class VideoSource implements Source
154 154
      */
155 155
     _handleAutoPlay(video: HTMLVideoElement): void
156 156
     {
157
+        // Autoplay guide: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide
158
+        // Chrome policy: https://developer.chrome.com/blog/autoplay/
159
+        // WebKit policy: https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
157 160
         Utils.assert(video.autoplay);
158 161
 
159 162
         // videos marked with autoplay should be muted
@@ -165,7 +168,7 @@ export class VideoSource implements Source
165 168
             const promise = video.play();
166 169
 
167 170
             // handle older browsers
168
-            if(typeof promise !== 'object')
171
+            if(promise === undefined)
169 172
                 return;
170 173
 
171 174
             // can't play the video
@@ -189,6 +192,12 @@ export class VideoSource implements Source
189 192
                         document.body.addEventListener('pointerdown', () => video.play());
190 193
                         alert('Tap on the screen to start');
191 194
                     }
195
+                    /*else {
196
+                        // play the video after the first interaction with the page
197
+                        const polling = setInterval(() => {
198
+                            video.play().then(() => clearInterval(polling));
199
+                        }, 500);
200
+                    }*/
192 201
                 }
193 202
 
194 203
                 // unsupported media source

Loading…
取消
儲存