Skip to content

Commit

Permalink
fixes #5 "pause/play does not resume buffering"
Browse files Browse the repository at this point in the history
  • Loading branch information
KozhinM committed Mar 13, 2014
1 parent 484265d commit a54524e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/js/streaming/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ MediaPlayer.dependencies.BufferController = function () {
rejectedBytes = null;
}

if (!self.requestScheduler.isScheduled(self)) {
if (!self.requestScheduler.isScheduled(self) && isSchedulingRequired.call(self)) {
doStart.call(self);
}

Expand Down Expand Up @@ -766,6 +766,13 @@ MediaPlayer.dependencies.BufferController = function () {
}
}
},

isSchedulingRequired = function() {
var isPaused = this.videoModel.isPaused();

return (!isPaused || (isPaused && this.scheduleWhilePaused));
},

/*
mseGetDesiredTime = function () {
var ranges = buffer.buffered,
Expand Down Expand Up @@ -884,6 +891,11 @@ MediaPlayer.dependencies.BufferController = function () {
checkIfSufficientBuffer.call(self);
//mseSetTimeIfPossible.call(self);

if (!isSchedulingRequired.call(self) && !initialPlayback) {
doStop.call(self);
return;
}

if (state === LOADING && bufferLevel < STALL_THRESHOLD) {
if (!stalled) {
self.debug.log("Stalling " + type + " Buffer: " + type);
Expand Down Expand Up @@ -976,6 +988,7 @@ MediaPlayer.dependencies.BufferController = function () {
debug: undefined,
system: undefined,
errHandler: undefined,
scheduleWhilePaused: undefined,

initialize: function (type, periodInfo, data, buffer, videoModel, scheduler, fragmentController, source) {
var self = this,
Expand Down
1 change: 1 addition & 0 deletions app/js/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ MediaPlayer = function (aContext) {
streamController.load(source);
system.mapValue("scheduleWhilePaused", scheduleWhilePaused);
system.mapOutlet("scheduleWhilePaused", "stream");
system.mapOutlet("scheduleWhilePaused", "bufferController");
system.mapValue("bufferMax", bufferMax);
system.injectInto(this.bufferExt, "bufferMax");
},
Expand Down
10 changes: 10 additions & 0 deletions app/js/streaming/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ MediaPlayer.dependencies.Stream = function () {

onPlay = function () {
this.debug.log("Got play event.");
startBuffering.call(this);
},

onPause = function () {
Expand Down Expand Up @@ -589,6 +590,15 @@ MediaPlayer.dependencies.Stream = function () {
}
},

startBuffering = function() {
if (videoController) {
videoController.start();
}
if (audioController) {
audioController.start();
}
},

stopBuffering = function() {
if (videoController) {
videoController.stop();
Expand Down

0 comments on commit a54524e

Please sign in to comment.