Workaround for https://github.com/adamcik/media-progress-timer/issues/3
Ensure that timer.js will keep on running until stopped explicitly by MMW.
This commit is contained in:
parent
f43a9a7afa
commit
9e4793b14d
@ -1,6 +1,6 @@
|
||||
CACHE MANIFEST
|
||||
|
||||
# 2016-04-06:v1
|
||||
# 2016-04-12:v1
|
||||
|
||||
NETWORK:
|
||||
*
|
||||
|
||||
@ -153,12 +153,14 @@
|
||||
|
||||
// TODO: Consider wrapping this in a try/catch?
|
||||
this._userCallback(userPosisition, state.duration);
|
||||
|
||||
if (state.position < state.duration) {
|
||||
// Workaround for https://github.com/adamcik/media-progress-timer/issues/3
|
||||
// Mopidy <= 1.1.2 does not always return the correct track position as
|
||||
// track changes are being done, which can cause the timer to die unexpectedly.
|
||||
//if (state.position < state.duration) {
|
||||
this._updateId = this._schedule(timestamp); // Schedule update.
|
||||
} else {
|
||||
this._updateId = null; // Unset since we didn't reschedule.
|
||||
}
|
||||
//} else {
|
||||
// this._updateId = null; // Unset since we didn't reschedule.
|
||||
//}
|
||||
};
|
||||
|
||||
return ProgressTimer;
|
||||
|
||||
@ -331,15 +331,6 @@ describe('SyncedTimer', function () {
|
||||
expect($('#songelapsed').text()).to.equal('0:01')
|
||||
assert.equal($('#trackslider').val(), 1000)
|
||||
})
|
||||
|
||||
it('should implement workaround for https://github.com/adamcik/media-progress-timer/issues/3', function () {
|
||||
syncedProgressTimer.set(1000, 2000).start()
|
||||
|
||||
assert.equal(syncedProgressTimer._duration, 2000)
|
||||
syncedProgressTimer.set(3000)
|
||||
assert.equal(syncedProgressTimer._progressTimer._state.position, 1999, 'Expected position to be less than duration')
|
||||
syncedProgressTimer.stop()
|
||||
})
|
||||
})
|
||||
|
||||
describe('#start()', function () {
|
||||
@ -510,4 +501,29 @@ describe('SyncedTimer', function () {
|
||||
syncedProgressTimer.stop()
|
||||
})
|
||||
})
|
||||
|
||||
describe('regression tests for https://github.com/adamcik/media-progress-timer/issues/3', function () {
|
||||
it('should not be possible to set position > duration', function () {
|
||||
syncedProgressTimer.set(1000, 2000).start()
|
||||
|
||||
assert.equal(syncedProgressTimer._duration, 2000)
|
||||
syncedProgressTimer.set(3000)
|
||||
assert.equal(syncedProgressTimer._progressTimer._state.position, 1999, 'Expected position to be less than duration')
|
||||
syncedProgressTimer.stop()
|
||||
})
|
||||
|
||||
it('should keep timer running even if an update would cause position > duration', function () {
|
||||
setFakeTimers()
|
||||
|
||||
clock.tick(0)
|
||||
clock.tick(1000)
|
||||
syncedProgressTimer.set(0, 1000).start()
|
||||
clock.tick(2000)
|
||||
|
||||
assert.isNotNull(syncedProgressTimer._progressTimer._updateId)
|
||||
syncedProgressTimer.stop()
|
||||
|
||||
restoreFakeTimers()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user