Skip to content
Open
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
45 changes: 45 additions & 0 deletions src-tauri/src/store/ui_state_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub struct UiState {
#[serde(default)]
pub audio: Option<crate::audio_output::AudioSettings>,
#[serde(default)]
pub surround_sound: Option<SurroundSoundState>,
#[serde(default)]
pub playback_adjustments: Option<PlaybackAdjustmentsState>,
#[serde(default)]
pub playback: Option<PlaybackState>,
Expand All @@ -65,6 +67,7 @@ impl Default for UiState {
settings: None,
rendering: None,
audio: None,
surround_sound: None,
playback_adjustments: None,
playback: None,
subtitle_appearance: None,
Expand All @@ -86,6 +89,12 @@ impl UiState {
settings: incoming.settings.or(self.settings),
rendering: incoming.rendering.or(self.rendering),
audio: incoming.audio.or(self.audio),
surround_sound: match (self.surround_sound, incoming.surround_sound) {
(Some(curr), Some(inc)) => Some(curr.merge(inc)),
(None, Some(inc)) => Some(inc),
(Some(curr), None) => Some(curr),
(None, None) => None,
},
playback_adjustments: incoming
.playback_adjustments
.or(self.playback_adjustments),
Expand Down Expand Up @@ -146,6 +155,42 @@ pub struct ColorAdjustmentsState {
pub hue: Option<f64>,
}

#[derive(Serialize, Deserialize, Clone, Default)]
#[serde(rename_all = "camelCase")]
pub struct SurroundSoundState {
#[serde(default)]
pub global_enabled: Option<bool>,
#[serde(default)]
pub enabled: Option<bool>,
#[serde(default)]
pub preset: Option<String>,
#[serde(default)]
pub surround_depth: Option<f64>,
#[serde(default)]
pub ambience: Option<f64>,
#[serde(default)]
pub clarity: Option<f64>,
#[serde(default)]
pub bass_boost: Option<f64>,
#[serde(default)]
pub dynamic_boost: Option<f64>,
}

impl SurroundSoundState {
fn merge(self, incoming: SurroundSoundState) -> SurroundSoundState {
SurroundSoundState {
global_enabled: incoming.global_enabled.or(self.global_enabled),
enabled: incoming.enabled.or(self.enabled),
preset: incoming.preset.or(self.preset),
surround_depth: incoming.surround_depth.or(self.surround_depth),
ambience: incoming.ambience.or(self.ambience),
clarity: incoming.clarity.or(self.clarity),
bass_boost: incoming.bass_boost.or(self.bass_boost),
dynamic_boost: incoming.dynamic_boost.or(self.dynamic_boost),
}
}
}

#[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SubtitleAppearanceState {
Expand Down
9 changes: 9 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { usePlaylistCreationPrompt } from "./composables/usePlaylistCreationProm
import { usePlaybackContextMenu } from "./composables/usePlaybackContextMenu";
import { useRemoteControlQrDialog } from "./composables/useRemoteControlQrDialog";
import { useAudioOutput } from "./composables/useAudioOutput";
import { useSurroundSound } from "./composables/useSurroundSound";
import { tauriCoreClient } from "./core-client/tauriPlaybackClient";
import { tauriPlaylistSourceClient } from "./core-client/tauriPlaylistSourceClient";

Expand Down Expand Up @@ -65,6 +66,7 @@ const {
isPipEnabled,
schedulePointerRefresh,
shouldKeepControlsVisible,
showSurroundMenu,
hideAllMenus,
toggleMenu,
closeAllMenus,
Expand All @@ -83,6 +85,11 @@ const {
normalizeStoredPanel,
} = useAppBootstrap(tauriCoreClient);

const {
applySurroundForMedia,
reapplyFilters: reapplySurround,
} = useSurroundSound();

const clearNavSelectionDuringLoad = ref(false);
const playbackLoadingState = usePlaybackLoadingState();
const { isLoading, loadingUrl } = playbackLoadingState;
Expand Down Expand Up @@ -455,6 +462,7 @@ const onFileLoaded = async () => {
await tracks.setSubtitlesDisabled(true);
}
await adjustments.applyColorAdjustmentsForMedia(player.state.media.url);
await applySurroundForMedia(player.state.media.url);
await subtitleAppearance.applySubtitleAppearanceOptions();
};

Expand Down Expand Up @@ -704,6 +712,7 @@ useAppStartupBindings({
:playback-rates="speed.playbackRates"
:show-speed-menu="speed.showSpeedMenu.value"
:show-settings-menu="adjustments.showSettingsMenu.value"
:show-surround-menu="showSurroundMenu"
:audio-delay="adjustments.audioDelay.value"
:sub-delay="adjustments.subDelay.value"
:secondary-sub-delay="adjustments.secondarySubDelay.value"
Expand Down
7 changes: 6 additions & 1 deletion src/components/PlayerControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const props = defineProps<{
playbackRates: number[];
showSpeedMenu: boolean;
showSettingsMenu: boolean;
showSurroundMenu: boolean;
audioDelay: number;
subDelay: number;
secondarySubDelay: number;
Expand Down Expand Up @@ -60,7 +61,10 @@ const emit = defineEmits<{
(e: "toggle-play-pause"): void;
(e: "stop-playback"): void;
(e: "next-track"): void;
(e: "toggle-menu", menuName: "audio" | "sub" | "speed" | "settings"): void;
(
e: "toggle-menu",
menuName: "audio" | "sub" | "speed" | "settings" | "surround",
): void;
(e: "toggle-loop-one"): void;
(e: "set-speed", rate: number): void;
(e: "set-speed-continuously", rate: number): void;
Expand Down Expand Up @@ -253,6 +257,7 @@ onUnmounted(() => {
:playback-rates="playbackRates"
:show-speed-menu="showSpeedMenu"
:show-settings-menu="showSettingsMenu"
:show-surround-menu="showSurroundMenu"
:speed-locked="audioPassthroughActive"
:audio-delay="audioDelay"
:sub-delay="subDelay"
Expand Down
Loading