fix(player): restore preserving html audio pitch

This commit is contained in:
Kendall Garner
2025-12-02 07:52:21 -08:00
parent f2b59d531b
commit bc5d0cf994
2 changed files with 16 additions and 2 deletions
@@ -1,6 +1,6 @@
import type { RefObject } from 'react'; import type { RefObject } from 'react';
import { useImperativeHandle, useRef, useState } from 'react'; import { useEffect, useImperativeHandle, useRef, useState } from 'react';
import ReactPlayer from 'react-player'; import ReactPlayer from 'react-player';
import { AudioPlayer, PlayerOnProgressProps } from '/@/renderer/features/player/audio-player/types'; import { AudioPlayer, PlayerOnProgressProps } from '/@/renderer/features/player/audio-player/types';
@@ -32,6 +32,7 @@ interface WebPlayerEngineProps {
playerNum: number; playerNum: number;
playerRef: RefObject<null | WebPlayerEngineHandle>; playerRef: RefObject<null | WebPlayerEngineHandle>;
playerStatus: PlayerStatus; playerStatus: PlayerStatus;
preservesPitch: boolean;
speed?: number; speed?: number;
src1: string | undefined; src1: string | undefined;
src2: string | undefined; src2: string | undefined;
@@ -59,6 +60,7 @@ export const WebPlayerEngine = (props: WebPlayerEngineProps) => {
playerNum, playerNum,
playerRef, playerRef,
playerStatus, playerStatus,
preservesPitch,
speed, speed,
src1, src1,
src2, src2,
@@ -149,6 +151,17 @@ export const WebPlayerEngine = (props: WebPlayerEngineProps) => {
}; };
}; };
useEffect(() => {
const player1 = player1Ref.current?.getInternalPlayer();
if (player1) {
player1.preservesPitch = preservesPitch;
}
const player2 = player2Ref.current?.getInternalPlayer();
if (player2) {
player2.preservesPitch = preservesPitch;
}
}, [preservesPitch]);
return ( return (
<div id="web-player-engine" style={{ display: 'none' }}> <div id="web-player-engine" style={{ display: 'none' }}>
<ReactPlayer <ReactPlayer
@@ -36,7 +36,7 @@ export function WebPlayer() {
const { crossfadeDuration, crossfadeStyle, speed, transitionType } = usePlayerProperties(); const { crossfadeDuration, crossfadeStyle, speed, transitionType } = usePlayerProperties();
const isMuted = usePlayerMuted(); const isMuted = usePlayerMuted();
const volume = usePlayerVolume(); const volume = usePlayerVolume();
const { transcode } = usePlaybackSettings(); const { preservePitch, transcode } = usePlaybackSettings();
const [localPlayerStatus, setLocalPlayerStatus] = useState<PlayerStatus>(status); const [localPlayerStatus, setLocalPlayerStatus] = useState<PlayerStatus>(status);
const [isTransitioning, setIsTransitioning] = useState<boolean | string>(false); const [isTransitioning, setIsTransitioning] = useState<boolean | string>(false);
@@ -432,6 +432,7 @@ export function WebPlayer() {
playerNum={num} playerNum={num}
playerRef={playerRef} playerRef={playerRef}
playerStatus={localPlayerStatus} playerStatus={localPlayerStatus}
preservesPitch={preservePitch}
speed={speed} speed={speed}
src1={player1Url} src1={player1Url}
src2={player2Url} src2={player2Url}