diff options
author | Hailey <me@haileyok.com> | 2024-08-09 03:25:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-09 11:25:54 +0100 |
commit | dd0d50a6f0f69d8b58f7dd26303b6b89528d2d04 (patch) | |
tree | 0bd8bc61efb8120b52937e2f6d3094009a760ad9 /src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx | |
parent | 0f993a09c2ac7147f9a555cb243c1aff8fc2e48c (diff) | |
download | voidsky-dd0d50a6f0f69d8b58f7dd26303b6b89528d2d04.tar.zst |
[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>
Diffstat (limited to 'src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx index 26f6111bc..576866260 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,11 +38,18 @@ export function VideoEmbedInnerNative() { player={player} style={a.flex_1} nativeControls={true} + onEnterFullscreen={() => { + PlatformInfo.setAudioMixWithOthers(false) + player.muted = false + }} + onExitFullscreen={() => { + PlatformInfo.setAudioMixWithOthers(true) + player.muted = true + }} /> <Controls player={player} enterFullscreen={() => { - player.muted = false ref.current?.enterFullscreen() }} /> @@ -89,7 +97,11 @@ function Controls({ }, [player]) const toggleSound = useCallback(() => { - 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 ( |