From 4aed6ce69e0585d8f6f8cca9d82de8007a445ddc Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 8 Aug 2024 20:36:54 -0700 Subject: [PATCH] fix audio problems --- src/App.native.tsx | 2 ++ .../VideoEmbedInner/VideoEmbedInnerNative.tsx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index d2c20fc8e7..29a6a738c5 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -61,6 +61,7 @@ import {Provider as PortalProvider} from '#/components/Portal' import {Splash} from '#/Splash' import {Provider as TourProvider} from '#/tours' import {BackgroundNotificationPreferencesProvider} from '../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider' +import {PlatformInfo} from '../modules/expo-bluesky-swiss-army' SplashScreen.preventAutoHideAsync() @@ -157,6 +158,7 @@ function App() { const [isReady, setReady] = useState(false) React.useEffect(() => { + PlatformInfo.setAudioMixWithOthers(true) initPersistedState().then(() => setReady(true)) }, []) diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx index 26f6111bc7..a1b6cd17b5 100644 --- a/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx +++ b/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx @@ -12,6 +12,7 @@ import {android, atoms as a, useTheme} from '#/alf' import {Mute_Stroke2_Corner0_Rounded as MuteIcon} from '#/components/icons/Mute' import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon} from '#/components/icons/Speaker' import {Text} from '#/components/Typography' +import {PlatformInfo} from '../../../../../../modules/expo-bluesky-swiss-army' export function VideoEmbedInnerNative() { const player = useVideoPlayer() @@ -37,6 +38,12 @@ export function VideoEmbedInnerNative() { player={player} style={a.flex_1} nativeControls={true} + onEnterFullscreen={() => { + PlatformInfo.setAudioMixWithOthers(false) + }} + onExitFullscreen={() => { + PlatformInfo.setAudioMixWithOthers(true) + }} /> { - player.muted = !player.muted + const newValue = !player.muted + // We want to set this to the _inverse_ of the new value, because we actually want for the audio to be mixed when + // the video is muted, and vice versa. + PlatformInfo.setAudioMixWithOthers(!newValue) + player.muted = newValue }, [player]) return (