Skip to content

Commit

Permalink
use promise and object.assign polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 18, 2018
1 parent cda9098 commit e26f78e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 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.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.20.0",
"version": "1.20.1",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",
Expand Down Expand Up @@ -53,6 +53,8 @@
"webpack-dev-server": "^2.9.5"
},
"dependencies": {
"balloon-css": "^0.5.0"
"balloon-css": "^0.5.0",
"object-assign": "4.1.1",
"promise-polyfill": "7.0.0"
}
}
3 changes: 2 additions & 1 deletion src/js/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global DPLAYER_VERSION GIT_HASH */
import objectAssign from 'object-assign';
import defaultApiBackend from './api.js';

export default (options) => {
Expand Down Expand Up @@ -116,7 +117,7 @@ export default (options) => {
}

if (options.icons) {
options.icons = Object.assign({}, defaultOption.icons, options.icons);
options.icons = objectAssign({}, defaultOption.icons, options.icons);
}

options.contextmenu = options.contextmenu.concat([
Expand Down
16 changes: 7 additions & 9 deletions src/js/player.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Promise from 'promise-polyfill';

import utils from './utils';
import handleOption from './options';
import i18n from './i18n';
Expand Down Expand Up @@ -175,15 +177,11 @@ class DPlayer {

this.template.playButton.innerHTML = this.icons.get('pause');

const playedPromise = this.video.play();
if (playedPromise) {
playedPromise.
catch(() => {
this.pause();
}).
then(() => {
});
}
const playedPromise = Promise.resolve(this.video.play());
playedPromise.catch(() => {
this.pause();
}).then(() => {
});
this.time.enable();
this.container.classList.add('dplayer-playing');
if (this.danmaku) {
Expand Down
6 changes: 5 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3358,7 +3358,7 @@ oauth-sign@~0.8.1, oauth-sign@~0.8.2:
version "0.8.2"
resolved "http://registry.npm.taobao.org/oauth-sign/download/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"

object-assign@^4.0.1, object-assign@^4.1.0:
object-assign@4.1.1, object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "http://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

Expand Down Expand Up @@ -3920,6 +3920,10 @@ progress@^2.0.0:
version "2.0.0"
resolved "http://registry.npm.taobao.org/progress/download/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"

[email protected]:
version "7.0.0"
resolved "http://registry.npm.taobao.org/promise-polyfill/download/promise-polyfill-7.0.0.tgz#c665b6da1f97e21c3f2f7aa0543c90209127cb15"

proxy-addr@~2.0.2:
version "2.0.2"
resolved "http://registry.npm.taobao.org/proxy-addr/download/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec"
Expand Down

0 comments on commit e26f78e

Please sign in to comment.