Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to select playback speed from a list of values #2771

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 41 additions & 14 deletions client/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Dropdown from '@/components/filter/Dropdown.vue';
import '@/assets/styles/popup.scss';
import { type SegmentOption, useSettingsStore } from '@/store/settings';
import CheckBox from '~/components/form/CheckBox.vue';

defineEmits<{
(e: 'close'): void;
Expand All @@ -18,6 +19,7 @@
]);

const videoQualities = ['144p', '240p', '360p', '720p', '1080p', '1440p', '2160p'];
const videoSpeedArray = ['0', '0.25', '0.5', '0.75', '1', '1.25', '1.5', '1.75', '2', '2.25', '2.5', '2.75', '3'];
</script>

<template>
Expand Down Expand Up @@ -232,6 +234,39 @@
@valuechange="val => settingsStore.setDefaultVideoQuality(val.value)"
/>
</div>
<div class="settings-number-menu">
<label for="video-speed-input">Default video speed</label>
<div class="video-speed-checkbox">
<label for="as-list" style="padding-right: 5px"> (as list ?)</label>
<CheckBox id="as-list"

Check warning on line 241 in client/components/Settings.vue

View workflow job for this annotation

GitHub Actions / lint:client

Expected a linebreak before this attribute
:value="settingsStore.videoSpeedAsList"
:label="''"
@valuechange="val => settingsStore.setVideoSpeedAsList(val)"
/>
</div>
<input v-if="!settingsStore.videoSpeedAsList"

Check warning on line 247 in client/components/Settings.vue

View workflow job for this annotation

GitHub Actions / lint:client

Expected a linebreak before this attribute
id="video-speed-input"
class="settings-number-input"
type="number"
name="video-speed"
:value="settingsStore.defaultVideoSpeed"
step="0.1"
max="3"
min="0.1"
@change="(e: any) => settingsStore.setDefaultVideoSpeed(parseFloat(e.target.value))"
/>
<Dropdown
v-if="settingsStore.videoSpeedAsList"
:style="{
'margin-top': '-20px',
'margin-right': '-20px',
'width': '63px'
}"
:values="videoSpeedArray"
:value="settingsStore.defaultVideoSpeed.toString()"
@valuechange="val => settingsStore.setDefaultVideoSpeed(val.value)"
/>
</div>
<SwitchButton
:value="settingsStore.dashPlaybackEnabled"
:label="'Enable MPEG-DASH'"
Expand Down Expand Up @@ -272,20 +307,6 @@
:right="true"
@valuechange="val => settingsStore.setAudioModeDefault(val)"
/>
<div class="settings-number-menu">
<label for="video-speed-input">Default video speed</label>
<input
id="video-speed-input"
class="settings-number-input"
type="number"
name="video-speed"
:value="settingsStore.defaultVideoSpeed"
step="0.1"
max="3"
min="0.1"
@change="(e: any) => settingsStore.setDefaultVideoSpeed(parseInt(e.target.value))"
/>
</div>
</div>
<div class="settings-overlay popup-overlay" @click.stop="$emit('close')" />
</div>
Expand Down Expand Up @@ -408,6 +429,12 @@
}
}

.video-speed-checkbox {
display: flex;
flex: 1;
margin-left: 5px;
}

.sponsorblock-options-container {
width: calc(100% - 36px);

Expand Down
1 change: 1 addition & 0 deletions client/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const useSettingsStore = defineStore(
reactive({
alwaysLoopVideo: false,
hideComments: false,
videoSpeedAsList: false,
audioModeDefault: false,
autoAdjustAudioQuality: true,
autoAdjustVideoQuality: true,
Expand Down
2 changes: 2 additions & 0 deletions server/src/user/settings/dto/settings.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class SettingsDto {

hideComments: boolean;

videoSpeedAsList: boolean;

autoplayNextVideo: boolean;

audioModeDefault: boolean;
Expand Down
3 changes: 3 additions & 0 deletions server/src/user/settings/schemas/settings.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export class Settings extends Document implements SettingsDto {
@Prop()
hideComments: boolean;

@Prop()
videoSpeedAsList: boolean;

@Prop()
autoplayNextVideo: boolean;

Expand Down
1 change: 1 addition & 0 deletions server/src/user/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class SettingsService {
private defaultOptions: SettingsDto = {
alwaysLoopVideo: false,
hideComments: false,
videoSpeedAsList: false,
audioModeDefault: false,
autoAdjustAudioQuality: true,
autoAdjustVideoQuality: true,
Expand Down
1 change: 1 addition & 0 deletions shared/api.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export interface components {
showRecommendedVideos: boolean;
alwaysLoopVideo: boolean;
hideComments: boolean;
videoSpeedAsList: boolean;
autoplayNextVideo: boolean;
audioModeDefault: boolean;
defaultVideoSpeed: number;
Expand Down
Loading