mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Video] Prevent pausing of background audio with `expo-video` on iOS (#4908)

* audio mixing pref

* lint

* patch expo video to add enter/exit fullscreen events

* rm logs

* fix audio problems

* toggle mute when enter/exiting fullscreen

---------

Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>

authored by hailey.at

Samuel Newman and committed by
GitHub
dd0d50a6 0f993a09

+16 -2
+2
src/App.native.tsx
··· 61 61 import {Splash} from '#/Splash' 62 62 import {Provider as TourProvider} from '#/tours' 63 63 import {BackgroundNotificationPreferencesProvider} from '../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider' 64 + import {PlatformInfo} from '../modules/expo-bluesky-swiss-army' 64 65 65 66 SplashScreen.preventAutoHideAsync() 66 67 ··· 157 158 const [isReady, setReady] = useState(false) 158 159 159 160 React.useEffect(() => { 161 + PlatformInfo.setAudioMixWithOthers(true) 160 162 initPersistedState().then(() => setReady(true)) 161 163 }, []) 162 164
+14 -2
src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
··· 12 12 import {Mute_Stroke2_Corner0_Rounded as MuteIcon} from '#/components/icons/Mute' 13 13 import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon} from '#/components/icons/Speaker' 14 14 import {Text} from '#/components/Typography' 15 + import {PlatformInfo} from '../../../../../../modules/expo-bluesky-swiss-army' 15 16 16 17 export function VideoEmbedInnerNative() { 17 18 const player = useVideoPlayer() ··· 37 38 player={player} 38 39 style={a.flex_1} 39 40 nativeControls={true} 41 + onEnterFullscreen={() => { 42 + PlatformInfo.setAudioMixWithOthers(false) 43 + player.muted = false 44 + }} 45 + onExitFullscreen={() => { 46 + PlatformInfo.setAudioMixWithOthers(true) 47 + player.muted = true 48 + }} 40 49 /> 41 50 <Controls 42 51 player={player} 43 52 enterFullscreen={() => { 44 - player.muted = false 45 53 ref.current?.enterFullscreen() 46 54 }} 47 55 /> ··· 89 97 }, [player]) 90 98 91 99 const toggleSound = useCallback(() => { 92 - player.muted = !player.muted 100 + const newValue = !player.muted 101 + // We want to set this to the _inverse_ of the new value, because we actually want for the audio to be mixed when 102 + // the video is muted, and vice versa. 103 + PlatformInfo.setAudioMixWithOthers(!newValue) 104 + player.muted = newValue 93 105 }, [player]) 94 106 95 107 return (