New API: play(time)
This commit is contained in:
parent
4ce9de0bd6
commit
1bc11bd62e
|
|
@ -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**
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue