Skip to content

Commit

Permalink
New api: switchQuality
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 18, 2017
1 parent bb33043 commit a4f5c2c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ <h2>Wow, such a lovely HTML5 danmaku video player</h2>
<h3>Normal</h3>
<div id="dplayer1"></div>
<button onclick="switchDPlayer()">Switch Video</button>
<button onclick="dp1.notice('Notice演示')">Notice</button>
<h3>Quality switching</h3>
<div id="dplayer6"></div>
<button onclick="dp6.switchQuality(1)">Switch quality</button>
<h3>Live Video (HTTP Live Streaming, M3U8 format) support</h3>
<div id="dplayer3"></div>
<h3>FLV format support</h3>
Expand Down
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.3.0",
"version": "1.3.1",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",
Expand Down
7 changes: 4 additions & 3 deletions src/DPlayer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.log('\n %c DPlayer 1.3.0 %c http://dplayer.js.org \n\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
console.log('\n %c DPlayer 1.3.1 %c http://dplayer.js.org \n\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');

require('./DPlayer.scss');
const utils = require('./utils.js');
Expand Down Expand Up @@ -756,7 +756,6 @@ class DPlayer {
this.element.getElementsByClassName('dplayer-quality-list')[0].addEventListener('click', (e) => {
if (e.target.classList.contains('dplayer-quality-item')) {
this.switchQuality(e.target.dataset.index);
this.element.getElementsByClassName('dplayer-quality-icon')[0].innerHTML = this.option.video.quality[this.qualityIndex].name;
}
});
}
Expand Down Expand Up @@ -1169,8 +1168,10 @@ class DPlayer {
this.qualityIndex = index;
}
this.switchingQuality = true;
this.video.pause();
this.quality = this.option.video.quality[index];
this.element.getElementsByClassName('dplayer-quality-icon')[0].innerHTML = this.quality.name;

this.video.pause();
const videoHTML = html.video(false, null, this.option.screenshot, 'auto', this.quality.url);
const videoEle = new DOMParser().parseFromString(videoHTML, 'text/html').body.firstChild;
const parent = this.element.getElementsByClassName('dplayer-video-wrap')[0];
Expand Down

0 comments on commit a4f5c2c

Please sign in to comment.