Skip to content

Commit 0416ece

Browse files
committed
Keep unplayed state until playback actually starts
Delay clearing the unplayed flag from the play action to the playing action. This prevents the player from briefly showind the last frame when playing again having played until the end. REDMINE-21248
1 parent 39b066f commit 0416ece

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

entry_types/scrolled/package/spec/frontend/usePlayerState-spec.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,25 @@ describe('usePlayerState', () => {
238238
expect(nextState.unplayed).toBe(true);
239239
});
240240

241-
it('is no longer unplayed after play action', () => {
241+
it('is no longer unplayed after playing action', () => {
242242
const {result} = renderHookInEntry(() => usePlayerState());
243243
const [,actions] = result.current;
244244
act(() => actions.play());
245+
act(() => actions.playing());
245246
const [nextState,] = result.current;
246247

247248
expect(nextState.unplayed).toBe(false);
248249
});
249250

251+
it('stays unplayed after play action until playing', () => {
252+
const {result} = renderHookInEntry(() => usePlayerState());
253+
const [,actions] = result.current;
254+
act(() => actions.play());
255+
const [nextState,] = result.current;
256+
257+
expect(nextState.unplayed).toBe(true);
258+
});
259+
250260
it('becomes unplayed again when video ends to make it return to its initial look', () => {
251261
const {result} = renderHookInEntry(() => usePlayerState());
252262
const [,actions] = result.current;

entry_types/scrolled/package/src/frontend/MediaPlayer/usePlayerState.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ export function playerStateReducer(state, action){
4242
isLoading: true,
4343
shouldPlay: true,
4444
playFailed: false,
45-
unplayed: false,
4645
lastControlledVia: action.payload.via
4746
};
4847
case PLAYING:
4948
return {
5049
...state,
5150
shouldPlay: true,
5251
isPlaying: true,
52+
unplayed: false,
5353
userIdle: false
5454
};
5555
case PLAY_AND_FADE_IN:

0 commit comments

Comments
 (0)