Modify lead function for lead-in
This commit is contained in:
parent
6a2e7bb9e2
commit
851491e4ac
3 changed files with 46 additions and 7 deletions
|
|
@ -510,18 +510,27 @@ Playlist.prototype.lead = function(lead) {
|
|||
}
|
||||
}
|
||||
|
||||
Playlist.prototype.startPlayback = function(time) {
|
||||
Playlist.prototype.startPlayback = function (time) {
|
||||
if(!this.current || !this.current.media)
|
||||
return false;
|
||||
this.current.media.paused = false;
|
||||
this.current.media.currentTime = time || -1;
|
||||
if (!this.leading) {
|
||||
this.current.media.paused = false;
|
||||
this.current.media.currentTime = time || 0;
|
||||
this.on("changeMedia")(this.current.media);
|
||||
return;
|
||||
}
|
||||
|
||||
time = time || -3;
|
||||
this.current.media.paused = time < 0;
|
||||
this.current.media.currentTime = time;
|
||||
|
||||
var pl = this;
|
||||
if(this._leadInterval) {
|
||||
clearInterval(this._leadInterval);
|
||||
this._leadInterval = false;
|
||||
}
|
||||
this.on("changeMedia")(this.current.media);
|
||||
if(this.leading && !isLive(this.current.media.type)) {
|
||||
if(!isLive(this.current.media.type)) {
|
||||
this._lastUpdate = Date.now();
|
||||
this._leadInterval = setInterval(function() {
|
||||
pl._leadLoop();
|
||||
|
|
@ -551,7 +560,20 @@ Playlist.prototype._leadLoop = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
this.current.media.currentTime += (Date.now() - this._lastUpdate) / 1000.0;
|
||||
var dt = (Date.now() - this._lastUpdate) / 1000.0;
|
||||
var t = this.current.media.currentTime;
|
||||
|
||||
// Transition from lead-in
|
||||
if (t < 0 && (t + dt) >= 0) {
|
||||
this.current.media.currentTime = 0;
|
||||
this.current.media.paused = false;
|
||||
this._counter = 0;
|
||||
this._lastUpdate = Date.now();
|
||||
this.on("mediaUpdate")(this.current.media);
|
||||
return;
|
||||
}
|
||||
|
||||
this.current.media.currentTime += dt;
|
||||
this._lastUpdate = Date.now();
|
||||
this._counter++;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue