allow disabling web audio
This commit is contained in:
parent
e68847f50a
commit
93055b3bf1
5 changed files with 38 additions and 4 deletions
|
@ -638,6 +638,8 @@
|
||||||
"volumeWheelStep_description": "the amount of volume to change when scrolling the mouse wheel on the volume slider",
|
"volumeWheelStep_description": "the amount of volume to change when scrolling the mouse wheel on the volume slider",
|
||||||
"volumeWidth": "volume slider width",
|
"volumeWidth": "volume slider width",
|
||||||
"volumeWidth_description": "the width of the volume slider",
|
"volumeWidth_description": "the width of the volume slider",
|
||||||
|
"webAudio": "use web audio",
|
||||||
|
"webAudio_description": "use web audio. this enables advanced features like replaygain. disable if you experience otherwise",
|
||||||
"windowBarStyle": "window bar style",
|
"windowBarStyle": "window bar style",
|
||||||
"windowBarStyle_description": "select the style of the window bar",
|
"windowBarStyle_description": "select the style of the window bar",
|
||||||
"zoom": "zoom percentage",
|
"zoom": "zoom percentage",
|
||||||
|
|
|
@ -69,6 +69,7 @@ export const AudioPlayer = forwardRef(
|
||||||
const [isTransitioning, setIsTransitioning] = useState(false);
|
const [isTransitioning, setIsTransitioning] = useState(false);
|
||||||
const audioDeviceId = useSettingsStore((state) => state.playback.audioDeviceId);
|
const audioDeviceId = useSettingsStore((state) => state.playback.audioDeviceId);
|
||||||
const playback = useSettingsStore((state) => state.playback.mpvProperties);
|
const playback = useSettingsStore((state) => state.playback.mpvProperties);
|
||||||
|
const useWebAudio = useSettingsStore((state) => state.playback.webAudio);
|
||||||
const { resetSampleRate } = useSettingsStoreActions();
|
const { resetSampleRate } = useSettingsStoreActions();
|
||||||
const playbackSpeed = useSpeed();
|
const playbackSpeed = useSpeed();
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ export const AudioPlayer = forwardRef(
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ('AudioContext' in window) {
|
if (useWebAudio && 'AudioContext' in window) {
|
||||||
let context: AudioContext;
|
let context: AudioContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { SelectItem } from '@mantine/core';
|
import { SelectItem, Switch } from '@mantine/core';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import { Select, Slider, toast } from '/@/renderer/components';
|
import { Select, Slider, toast } from '/@/renderer/components';
|
||||||
import {
|
import {
|
||||||
|
@ -132,6 +132,27 @@ export const AudioSettings = ({ hasFancyAudio }: { hasFancyAudio: boolean }) =>
|
||||||
postProcess: 'sentenceCase',
|
postProcess: 'sentenceCase',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
control: (
|
||||||
|
<Switch
|
||||||
|
defaultChecked={settings.webAudio}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSettings({
|
||||||
|
playback: { ...settings, webAudio: e.currentTarget.checked },
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
description: t('setting.webAudio', {
|
||||||
|
context: 'description',
|
||||||
|
postProcess: 'sentenceCase',
|
||||||
|
}),
|
||||||
|
isHidden: settings.type !== PlaybackType.WEB,
|
||||||
|
note: t('common.restartRequired', { postProcess: 'sentenceCase' }),
|
||||||
|
title: t('setting.webAudio', {
|
||||||
|
postProcess: 'sentenceCase',
|
||||||
|
}),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
control: (
|
control: (
|
||||||
<Slider
|
<Slider
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { AudioSettings } from '/@/renderer/features/settings/components/playback
|
||||||
import { ScrobbleSettings } from '/@/renderer/features/settings/components/playback/scrobble-settings';
|
import { ScrobbleSettings } from '/@/renderer/features/settings/components/playback/scrobble-settings';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import { LyricSettings } from '/@/renderer/features/settings/components/playback/lyric-settings';
|
import { LyricSettings } from '/@/renderer/features/settings/components/playback/lyric-settings';
|
||||||
|
import { useSettingsStore } from '/@/renderer/store';
|
||||||
|
import { PlaybackType } from '/@/renderer/types';
|
||||||
|
|
||||||
const MpvSettings = lazy(() =>
|
const MpvSettings = lazy(() =>
|
||||||
import('/@/renderer/features/settings/components/playback/mpv-settings').then((module) => {
|
import('/@/renderer/features/settings/components/playback/mpv-settings').then((module) => {
|
||||||
|
@ -12,9 +14,15 @@ const MpvSettings = lazy(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const PlaybackTab = () => {
|
export const PlaybackTab = () => {
|
||||||
|
const audioType = useSettingsStore((state) => state.playback.type);
|
||||||
|
const useWebAudio = useSettingsStore((state) => state.playback.webAudio);
|
||||||
|
|
||||||
const hasFancyAudio = useMemo(() => {
|
const hasFancyAudio = useMemo(() => {
|
||||||
return isElectron() || 'AudioContext' in window;
|
return (
|
||||||
}, []);
|
(isElectron() && audioType === PlaybackType.LOCAL) ||
|
||||||
|
(useWebAudio && 'AudioContext' in window)
|
||||||
|
);
|
||||||
|
}, [audioType, useWebAudio]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing="md">
|
<Stack spacing="md">
|
||||||
|
|
|
@ -265,6 +265,7 @@ export interface SettingsState {
|
||||||
};
|
};
|
||||||
style: PlaybackStyle;
|
style: PlaybackStyle;
|
||||||
type: PlaybackType;
|
type: PlaybackType;
|
||||||
|
webAudio: boolean;
|
||||||
};
|
};
|
||||||
remote: {
|
remote: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
|
@ -439,6 +440,7 @@ const initialState: SettingsState = {
|
||||||
},
|
},
|
||||||
style: PlaybackStyle.GAPLESS,
|
style: PlaybackStyle.GAPLESS,
|
||||||
type: PlaybackType.WEB,
|
type: PlaybackType.WEB,
|
||||||
|
webAudio: true,
|
||||||
},
|
},
|
||||||
remote: {
|
remote: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
Reference in a new issue