Selaa lähdekoodia

Update VideoSource._handleAutoPlay()

customisations
alemart 1 vuosi sitten
vanhempi
commit
dbfdc69c91
1 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 10
    1
      src/sources/video-source.ts

+ 10
- 1
src/sources/video-source.ts Näytä tiedosto

154
      */
154
      */
155
     _handleAutoPlay(video: HTMLVideoElement): void
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
         Utils.assert(video.autoplay);
160
         Utils.assert(video.autoplay);
158
 
161
 
159
         // videos marked with autoplay should be muted
162
         // videos marked with autoplay should be muted
165
             const promise = video.play();
168
             const promise = video.play();
166
 
169
 
167
             // handle older browsers
170
             // handle older browsers
168
-            if(typeof promise !== 'object')
171
+            if(promise === undefined)
169
                 return;
172
                 return;
170
 
173
 
171
             // can't play the video
174
             // can't play the video
189
                         document.body.addEventListener('pointerdown', () => video.play());
192
                         document.body.addEventListener('pointerdown', () => video.play());
190
                         alert('Tap on the screen to start');
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
                 // unsupported media source
203
                 // unsupported media source

Loading…
Peruuta
Tallenna