Prechádzať zdrojové kódy

minor modification for preview

DIYgod 8 rokov pred
rodič
commit
47cb3f6615

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/DPlayer.min.css


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/DPlayer.min.css.map


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/DPlayer.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/DPlayer.min.js.map


+ 15 - 9
src/DPlayer.js

@@ -1114,7 +1114,7 @@ class DPlayer {
             case 'mousemove':
                 this.isMouseHoverPbar = true;
                 this.setPreviewSourceAndFrame({
-                    url: this.video.current.src,
+                    url: this.video.src,
                     time
                 });
                 this.timeTipsDisplay(true, timeTips);
@@ -1151,16 +1151,22 @@ class DPlayer {
         this.previewCanvas = this.element.getElementsByClassName('dplayer-bar-preview-canvas')[0];
 
         this.previewVideo.preload = 'auto';
-        const w = this.element.offsetWidth / 3;
-        const h = this.element.offsetHeight / 3;
-        this.previewWrapper.style.width = `${w}px`;
-        this.previewWrapper.style.height = `${h}px`;
-        this.previewWrapper.style.top = `${-h}px`;
-        this.previewCanvas.width = w;
-        this.previewCanvas.height = h;
+        const resize = () => {
+            const w = this.element.offsetWidth / 4;
+            const h = this.element.offsetHeight / 4;
+            this.previewWrapper.style.width = `${w}px`;
+            this.previewWrapper.style.height = `${h}px`;
+            this.previewWrapper.style.top = `${-h + 2}px`;
+            this.previewCanvas.width = w;
+            this.previewCanvas.height = h;
+        };
+        resize();
+        this.video.addEventListener('loadedmetadata', () => {
+            resize();
+        });
 
         this.setPreviewSourceAndFrame({
-            url: this.video.current.src, time: 0
+            url: this.video.src, time: 0
         });
         this.bindPreviewEvent();
     }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov