Skip to content

Commit

Permalink
fix audio problems
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Aug 9, 2024
1 parent 656afda commit 4aed6ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/App.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -157,6 +158,7 @@ function App() {
const [isReady, setReady] = useState(false)

React.useEffect(() => {
PlatformInfo.setAudioMixWithOthers(true)
initPersistedState().then(() => setReady(true))
}, [])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -37,6 +38,12 @@ export function VideoEmbedInnerNative() {
player={player}
style={a.flex_1}
nativeControls={true}
onEnterFullscreen={() => {
PlatformInfo.setAudioMixWithOthers(false)
}}
onExitFullscreen={() => {
PlatformInfo.setAudioMixWithOthers(true)
}}
/>
<Controls
player={player}
Expand Down Expand Up @@ -89,7 +96,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 (
Expand Down

0 comments on commit 4aed6ce

Please sign in to comment.