feat: add new preference to unmute videos by default (#3218)

This commit is contained in:
TAKAHASHI Shuuji 2025-03-02 23:55:00 +09:00 committed by GitHub
parent 60b1d0224c
commit 41379627b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

View file

@ -71,6 +71,7 @@ const isVideo = computed(() => attachment.type === 'video')
const isGif = computed(() => attachment.type === 'gifv') const isGif = computed(() => attachment.type === 'gifv')
const enableAutoplay = usePreferences('enableAutoplay') const enableAutoplay = usePreferences('enableAutoplay')
const unmuteVideos = usePreferences('unmuteVideos')
useIntersectionObserver(video, (entries) => { useIntersectionObserver(video, (entries) => {
const ready = video.value?.dataset.ready === 'true' const ready = video.value?.dataset.ready === 'true'
@ -132,7 +133,7 @@ watch(shouldLoadAttachment, () => {
ref="video" ref="video"
preload="none" preload="none"
:poster="videoThumbnail" :poster="videoThumbnail"
muted :muted="!unmuteVideos"
loop loop
playsinline playsinline
:controls="shouldLoadAttachment" :controls="shouldLoadAttachment"
@ -172,7 +173,7 @@ watch(shouldLoadAttachment, () => {
ref="video" ref="video"
preload="none" preload="none"
:poster="videoThumbnail" :poster="videoThumbnail"
muted :muted="!unmuteVideos"
loop loop
playsinline playsinline
rounded-lg rounded-lg

View file

@ -23,6 +23,7 @@ export interface PreferencesSettings {
hideNews: boolean hideNews: boolean
grayscaleMode: boolean grayscaleMode: boolean
enableAutoplay: boolean enableAutoplay: boolean
unmuteVideos: boolean
optimizeForLowPerformanceDevice: boolean optimizeForLowPerformanceDevice: boolean
enableDataSaving: boolean enableDataSaving: boolean
enablePinchToZoom: boolean enablePinchToZoom: boolean
@ -79,6 +80,7 @@ export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
hideNews: false, hideNews: false,
grayscaleMode: false, grayscaleMode: false,
enableAutoplay: true, enableAutoplay: true,
unmuteVideos: false,
optimizeForLowPerformanceDevice: false, optimizeForLowPerformanceDevice: false,
enableDataSaving: false, enableDataSaving: false,
enablePinchToZoom: false, enablePinchToZoom: false,

View file

@ -561,6 +561,7 @@
"label": "Preferences", "label": "Preferences",
"optimize_for_low_performance_device": "Optimize for low performance device", "optimize_for_low_performance_device": "Optimize for low performance device",
"title": "Experimental Features", "title": "Experimental Features",
"unmute_videos": "Unmute videos by default",
"use_star_favorite_icon": "Use star favorite icon", "use_star_favorite_icon": "Use star favorite icon",
"user_picker": "User Picker", "user_picker": "User Picker",
"user_picker_description": "Displays all avatars of logged accounts in the bottom-left so you can switch quickly between them.", "user_picker_description": "Displays all avatars of logged accounts in the bottom-left so you can switch quickly between them.",

View file

@ -51,6 +51,12 @@ const userSettings = useUserSettings()
> >
{{ $t('settings.preferences.enable_autoplay') }} {{ $t('settings.preferences.enable_autoplay') }}
</SettingsToggleItem> </SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'unmuteVideos')"
@click="togglePreferences('unmuteVideos')"
>
{{ $t('settings.preferences.unmute_videos') }}
</SettingsToggleItem>
<SettingsToggleItem <SettingsToggleItem
:checked="getPreferences(userSettings, 'optimizeForLowPerformanceDevice')" :checked="getPreferences(userSettings, 'optimizeForLowPerformanceDevice')"
@click="togglePreferences('optimizeForLowPerformanceDevice')" @click="togglePreferences('optimizeForLowPerformanceDevice')"