1
0
DIYgod 7 жил өмнө
parent
commit
15631ecc59

+ 6 - 6
src/js/DPlayer.js

@@ -1,4 +1,4 @@
-import utils, { isMobile } from './utils';
+import utils from './utils';
 import handleOption from './options';
 import i18n from './i18n';
 import Template from './template';
@@ -48,7 +48,7 @@ class DPlayer {
         if (this.options.live) {
             this.container.classList.add('dplayer-live');
         }
-        if (isMobile) {
+        if (utils.isMobile) {
             this.container.classList.add('dplayer-mobile');
         }
         this.arrow = this.container.offsetWidth <= 500;
@@ -83,10 +83,10 @@ class DPlayer {
                         this.template.danmakuLoading.style.display = 'none';
 
                         // autoplay
-                        if (this.options.autoplay && !isMobile) {
+                        if (this.options.autoplay && !utils.isMobile) {
                             this.play();
                         }
-                        else if (isMobile) {
+                        else if (utils.isMobile) {
                             this.pause();
                         }
                     }, 0);
@@ -128,10 +128,10 @@ class DPlayer {
 
         if (!this.danmaku) {
             // autoplay
-            if (this.options.autoplay && !isMobile) {
+            if (this.options.autoplay && !utils.isMobile) {
                 this.play();
             }
-            else if (isMobile) {
+            else if (utils.isMobile) {
                 this.pause();
             }
         }

+ 3 - 3
src/js/controller.js

@@ -1,4 +1,4 @@
-import utils, { isMobile } from './utils';
+import utils from './utils';
 import Thumbnails from './thumbnails';
 
 class Controller {
@@ -6,7 +6,7 @@ class Controller {
         this.player = player;
 
         this.autoHideTimer = 0;
-        if (!isMobile) {
+        if (!utils.isMobile) {
             this.player.container.addEventListener('mousemove', () => {
                 this.setAutoHide();
             });
@@ -30,7 +30,7 @@ class Controller {
             this.player.toggle();
         });
 
-        if (!isMobile) {
+        if (!utils.isMobile) {
             this.player.template.videoWrap.addEventListener('click', () => {
                 this.player.toggle();
             });

+ 2 - 2
src/js/options.js

@@ -1,10 +1,10 @@
 /* global DPLAYER_VERSION GIT_HASH */
 import defaultApiBackend from './api.js';
+import utils from './utils';
 
 export default (options) => {
-    const isMobile = /mobile/i.test(window.navigator.userAgent);
     // compatibility: some mobile browsers don't suppose autoplay
-    if (isMobile) {
+    if (utils.isMobile) {
         options.autoplay = false;
     }