New API: play(time)

This commit is contained in:
DIYgod 2016-07-15 10:33:20 +08:00
parent 4ce9de0bd6
commit 1bc11bd62e
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
5 changed files with 15 additions and 11 deletions

View File

@ -65,9 +65,11 @@ var option = {
**API**
+ `dp.init()`
+ `dp.play()`
+ `dp.pause()`
+ `dp.init()` // Load player
+ `dp.play()` // Resume play
+ `dp.play(time)` // Set currentTime
+ `dp.pause()` // Pause
+ `ap.on(event, handler)` // Event binding
**Event binding**

4
dist/DPlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.0.1",
"version": "1.0.2",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"scripts": {

View File

@ -421,8 +421,7 @@ class DPlayer {
let item = this.dan[this.danIndex];
while (item && this.audio.currentTime >= parseFloat(item.time)) {
this.danmakuIn(item.text, item.color, item.type);
this.danIndex++;
item = this.dan[this.danIndex];
item = this.dan[++this.danIndex];
}
}, 0);
}
@ -843,12 +842,12 @@ class DPlayer {
item.classList.add(`dplayer-danmaku-${type}`);
item.innerHTML = text;
item.style.opacity = this.danOpacity;
item.style.color = color;
// insert
danContainer.appendChild(item);
// adjust
item.style.color = color;
switch (type) {
case 'right':
item.style.top = itemHeight * getTunnel(item, type) + 'px';
@ -1176,7 +1175,10 @@ class DPlayer {
/**
* Play music
*/
play() {
play(time) {
if (Object.prototype.toString.call(time) === '[object Number]') {
this.audio.currentTime = time;
}
if (this.audio.paused) {
this.shouldpause = false;