Skip to content

Commit

Permalink
New option: preload
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Aug 28, 2016
1 parent 60d90b1 commit e626ece
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var option = {
lang: 'zh', // Optional, language, `zh` for Chinese, `en` for English, default: Navigator language
screenshot: true, // Optional, enable screenshot function, default: false, NOTICE: if set it to true, video and video poster must enable Cross-Origin
hotkey: true, // Optional, binding hot key, including left right and Space, default: true
preload: 'auto', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
video: { // Required, video info
url: '若能绽放光芒.mp4', // Required, video url
pic: '若能绽放光芒.png' // Optional, music picture
Expand Down
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.

5 changes: 3 additions & 2 deletions src/DPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class DPlayer {
loop: false,
lang: navigator.language.indexOf('zh') !== -1 ? 'zh' : 'en',
screenshot: false,
hotkey: true
hotkey: true,
preload: 'auto'
};
for (let defaultKey in defaultOption) {
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
Expand Down Expand Up @@ -117,7 +118,7 @@ class DPlayer {
this.element.innerHTML = `
<div class="dplayer-mask"></div>
<div class="dplayer-video-wrap">
<video class="dplayer-video" ${option.video.pic ? `poster="${option.video.pic}"` : ``} ${option.screenshot ? `crossorigin="anonymous"` : ``}>
<video class="dplayer-video" ${option.video.pic ? `poster="${option.video.pic}"` : ``} ${option.screenshot ? `crossorigin="anonymous"` : ``} preload="${option.preload}">
<source src="${option.video.url}">
</video>
<div class="dplayer-danmaku">
Expand Down

0 comments on commit e626ece

Please sign in to comment.