Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
main: forcing show the spinner when buffer is almost empty (close #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioribeiro committed Aug 2, 2014
1 parent 9ccaa8f commit 1e5e922
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ class P2PHLS extends UIPlugin {
}

updateBufferLength() {
var bufferLength = this.el.globoGetbufferLength() || 0
this.triggerStats({bufferLength: bufferLength})
this.bufferLength = this.el.globoGetbufferLength() || 0
this.triggerStats({bufferLength: this.bufferLength})
if (this.bufferLength < 1 && this.currentState == 'PLAYING') {
this.setPlaybackState('PLAYING_BUFFERING')
} else if (this.currentState == "PLAYING_BUFFERING") {
this.setPlaybackState('PLAYING')
}
}

triggerStats(metrics) {
Expand Down Expand Up @@ -162,7 +167,7 @@ class P2PHLS extends UIPlugin {
}

setPlaybackState(state) {
if (state === "PLAYING_BUFFERING" && this.el.globoGetbufferLength() < 1 && this.currentState !== "PLAYING_BUFFERING") {
if (state === "PLAYING_BUFFERING" && this.bufferLength < 1) {
this.trigger('playback:buffering', this.name)
} else if (state === "PLAYING" && this.currentState === "PLAYING_BUFFERING") {
this.trigger('playback:bufferfull', this.name)
Expand Down

0 comments on commit 1e5e922

Please sign in to comment.