Browse Source

Change the logic of VideoSource._waitUntilPlayable()

customisations
alemart 1 year ago
parent
commit
6287355cd6
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      src/sources/video-source.ts

+ 4
- 3
src/sources/video-source.ts View File

256
     /**
256
     /**
257
      * Wait for the input video to be playable
257
      * Wait for the input video to be playable
258
      * @param video
258
      * @param video
259
-     * @returns a promise that resolves to the input video when it can be played through to the end
259
+     * @returns a promise that resolves to the input video when it can be played
260
      */
260
      */
261
     private _waitUntilPlayable(video: HTMLVideoElement): SpeedyPromise<HTMLVideoElement>
261
     private _waitUntilPlayable(video: HTMLVideoElement): SpeedyPromise<HTMLVideoElement>
262
     {
262
     {
263
         const TIMEOUT = 15000, INTERVAL = 500;
263
         const TIMEOUT = 15000, INTERVAL = 500;
264
 
264
 
265
-        if(video.readyState >= 4)
265
+        if(video.readyState >= 3)
266
             return Speedy.Promise.resolve(video);
266
             return Speedy.Promise.resolve(video);
267
 
267
 
268
         return new Speedy.Promise<HTMLVideoElement>((resolve, reject) => {
268
         return new Speedy.Promise<HTMLVideoElement>((resolve, reject) => {
269
             let ms = 0, t = setInterval(() => {
269
             let ms = 0, t = setInterval(() => {
270
 
270
 
271
-                if(video.readyState >= 4) { // canplaythrough
271
+                //if(video.readyState >= 4) { // canplaythrough (may timeout on slow connections)
272
+                if(video.readyState >= 3) {
272
                     clearInterval(t);
273
                     clearInterval(t);
273
                     resolve(video);
274
                     resolve(video);
274
                 }
275
                 }

Loading…
Cancel
Save