Merge pull request #759 from jellyfin/playback-fix

fix(playback manager): reset time when moving between tracks
This commit is contained in:
Julien Machiels 2021-02-25 20:25:50 +01:00 committed by GitHub
commit 7b614c49b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -256,13 +256,15 @@ test('When "INCREASE_QUEUE_INDEX" is committed, currentItemIndex is increased. C
store.replaceState({
...defaultState(),
currentItemIndex: 1,
lastItemIndex: 0
lastItemIndex: 0,
currentTime: 100
});
store.commit('INCREASE_QUEUE_INDEX');
expect(store.state.currentItemIndex).toBe(2);
expect(store.state.lastItemIndex).toBe(1);
expect(store.state.currentTime).toBe(0);
});
test('When "DECREASE_QUEUE_INDEX" is committed, currentItemIndex is decreased. Case A', () => {
@ -278,12 +280,14 @@ test('When "DECREASE_QUEUE_INDEX" is committed, currentItemIndex is decreased. C
test('When "DECREASE_QUEUE_INDEX" is committed, currentItemIndex is decreased. Case B', () => {
store.replaceState({
...defaultState(),
currentItemIndex: 2
currentItemIndex: 2,
currentTime: 1
});
store.commit('DECREASE_QUEUE_INDEX');
expect(store.state.currentItemIndex).toBe(1);
expect(store.state.currentTime).toBe(0);
});
test('When "START_PLAYBACK" is committed, status is set to playing.', () => {

View File

@ -167,11 +167,14 @@ export const mutations: MutationTree<PlaybackManagerState> = {
if (state.currentItemIndex !== null) {
state.lastItemIndex = state.currentItemIndex;
state.currentItemIndex += 1;
state.currentTime = 0;
}
},
DECREASE_QUEUE_INDEX(state: PlaybackManagerState) {
if (state.currentItemIndex !== null) {
state.lastItemIndex = state.currentItemIndex;
state.currentItemIndex -= 1;
state.currentTime = 0;
}
},
START_PLAYBACK(