Skip to content

Commit

Permalink
Use native video in mobile(close: #26); Fix UMD bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Sep 25, 2016
1 parent ba3be09 commit 9fb38b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/DPlayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/DPlayer.min.js.map

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/DPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DPlayer {
`;
};

const isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);
const isMobile = /mobile/i.test(window.navigator.userAgent);
// compatibility: some mobile browsers don't suppose autoplay
if (isMobile) {
option.autoplay = false;
Expand Down Expand Up @@ -117,6 +117,16 @@ class DPlayer {
this.element.classList.add('dplayer-no-danmaku');
}

if (isMobile) {
this.element.innerHTML = `
<div class="dplayer-video-wrap">
<video class="dplayer-video" ${option.video.pic ? `poster="${option.video.pic}"` : ``} preload="${option.preload}" controls>
<source src="${option.video.url}">
</video>
</div>`;
return;
}

this.element.innerHTML = `
<div class="dplayer-mask"></div>
<div class="dplayer-video-wrap">
Expand Down Expand Up @@ -1305,4 +1315,4 @@ class DPlayer {
}
}

export {DPlayer};
module.exports = DPlayer;
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
output: {
path: BUILD_PATH,
filename: 'DPlayer.min.js',
library: 'DPlayer',
libraryTarget: 'umd',
umdNamedDefine: true
},
Expand Down

0 comments on commit 9fb38b1

Please sign in to comment.