mirror of
https://github.com/zoriya/v10.git
synced 2026-08-13 17:40:12 +00:00
fix(core): use 0.2 and 0.7 for default playback rates (#1236)
This commit is contained in:
+4
-4
@@ -6,7 +6,7 @@ import { PlaybackRateButtonCore } from '../playback-rate-button-core';
|
||||
|
||||
function createMediaState(overrides: Partial<MediaPlaybackRateState> = {}): MediaPlaybackRateState {
|
||||
return {
|
||||
playbackRates: [0.25, 0.5, 0.75, 1, 1.2, 1.5, 1.7, 2],
|
||||
playbackRates: [0.2, 0.5, 0.7, 1, 1.2, 1.5, 1.7, 2],
|
||||
playbackRate: 1,
|
||||
setPlaybackRate: vi.fn(),
|
||||
...overrides,
|
||||
@@ -96,7 +96,7 @@ describe('PlaybackRateButtonCore', () => {
|
||||
const core = new PlaybackRateButtonCore();
|
||||
const media = createMediaState({ playbackRate: 2 });
|
||||
core.cycle(media);
|
||||
expect(media.setPlaybackRate).toHaveBeenCalledWith(0.25);
|
||||
expect(media.setPlaybackRate).toHaveBeenCalledWith(0.2);
|
||||
});
|
||||
|
||||
it('advances through the middle of the list', () => {
|
||||
@@ -124,12 +124,12 @@ describe('PlaybackRateButtonCore', () => {
|
||||
const core = new PlaybackRateButtonCore();
|
||||
const media = createMediaState({ playbackRate: 3 });
|
||||
core.cycle(media);
|
||||
expect(media.setPlaybackRate).toHaveBeenCalledWith(0.25);
|
||||
expect(media.setPlaybackRate).toHaveBeenCalledWith(0.2);
|
||||
});
|
||||
|
||||
it('cycles through sub-1x rates', () => {
|
||||
const core = new PlaybackRateButtonCore();
|
||||
const media = createMediaState({ playbackRate: 0.25 });
|
||||
const media = createMediaState({ playbackRate: 0.2 });
|
||||
core.cycle(media);
|
||||
expect(media.setPlaybackRate).toHaveBeenCalledWith(0.5);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { listen } from '@videojs/utils/dom';
|
||||
import type { MediaPlaybackRateState } from '../../../core/media/state';
|
||||
import { definePlayerFeature } from '../../feature';
|
||||
|
||||
const DEFAULT_RATES: readonly number[] = [0.25, 0.5, 0.75, 1, 1.2, 1.5, 1.7, 2];
|
||||
const DEFAULT_RATES: readonly number[] = [0.2, 0.5, 0.7, 1, 1.2, 1.5, 1.7, 2];
|
||||
|
||||
export const playbackRateFeature = definePlayerFeature({
|
||||
name: 'playbackRate',
|
||||
|
||||
@@ -37,7 +37,7 @@ import basicUsageHtmlTs from "@/components/docs/demos/playback-rate-button/html/
|
||||
|
||||
## Behavior
|
||||
|
||||
Cycles through playback rates on click. The default rate list is `[1, 1.2, 1.5, 1.7, 2]`. After the last rate, it wraps back to the first. If the current rate isn't in the list (e.g., set programmatically), the button jumps to the next rate greater than the current one.
|
||||
Cycles through playback rates on click. The default rate list is `[0.2, 0.5, 0.7, 1, 1.2, 1.5, 1.7, 2]`. After the last rate, it wraps back to the first. If the current rate isn't in the list (e.g., set programmatically), the button jumps to the next rate greater than the current one.
|
||||
|
||||
## Styling
|
||||
|
||||
|
||||
Reference in New Issue
Block a user