Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

[Video] Resume background audio whenever muting video audio (#4915)

authored by

Hailey and committed by
GitHub
65d6e561 c2131bb0

+28 -17
+15 -6
modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift
··· 13 13 try? AVAudioSession.sharedInstance().setCategory(audioCategory) 14 14 } 15 15 16 - Function("setAudioMixWithOthers") { (mixWithOthers: Bool) in 17 - var options: AVAudioSession.CategoryOptions 16 + Function("setAudioActive") { (active: Bool) in 17 + var categoryOptions: AVAudioSession.CategoryOptions 18 18 let currentCategory = AVAudioSession.sharedInstance().category 19 - if mixWithOthers { 20 - options = [.mixWithOthers] 19 + 20 + if active { 21 + categoryOptions = [.mixWithOthers] 22 + try? AVAudioSession.sharedInstance().setActive(true) 21 23 } else { 22 - options = [.duckOthers] 24 + categoryOptions = [.duckOthers] 25 + try? AVAudioSession 26 + .sharedInstance() 27 + .setActive( 28 + false, 29 + options: [.notifyOthersOnDeactivation] 30 + ) 23 31 } 32 + 24 33 try? AVAudioSession 25 34 .sharedInstance() 26 35 .setCategory( 27 36 currentCategory, 28 37 mode: .default, 29 - options: options 38 + options: categoryOptions 30 39 ) 31 40 } 32 41 }
+2 -2
modules/expo-bluesky-swiss-army/src/PlatformInfo/index.native.ts
··· 9 9 return NativeModule.getIsReducedMotionEnabled() 10 10 } 11 11 12 - export function setAudioMixWithOthers(mixWithOthers: boolean): void { 12 + export function setAudioActive(active: boolean): void { 13 13 if (Platform.OS !== 'ios') return 14 - NativeModule.setAudioMixWithOthers(mixWithOthers) 14 + NativeModule.setAudioActive(active) 15 15 } 16 16 17 17 export function setAudioCategory(audioCategory: AudioCategory): void {
+5 -3
modules/expo-bluesky-swiss-army/src/PlatformInfo/index.ts
··· 6 6 } 7 7 8 8 /** 9 - * Set whether the app's audio should mix with other apps' audio. 9 + * Set whether the app's audio should mix with other apps' audio. Will also resume background music playback when `false` 10 + * if it was previously playing. 10 11 * @param mixWithOthers 12 + * @see https://developer.apple.com/documentation/avfaudio/avaudiosession/setactiveoptions/1616603-notifyothersondeactivation 11 13 */ 12 - export function setAudioMixWithOthers(mixWithOthers: boolean): void { 13 - throw new NotImplementedError({mixWithOthers}) 14 + export function setAudioActive(active: boolean): void { 15 + throw new NotImplementedError({active}) 14 16 } 15 17 16 18 /**
+2 -2
modules/expo-bluesky-swiss-army/src/PlatformInfo/index.web.ts
··· 8 8 return window.matchMedia('(prefers-reduced-motion: reduce)').matches 9 9 } 10 10 11 - export function setAudioMixWithOthers(mixWithOthers: boolean): void { 12 - throw new NotImplementedError({mixWithOthers}) 11 + export function setAudioActive(active: boolean): void { 12 + throw new NotImplementedError({active}) 13 13 } 14 14 15 15 export function setAudioCategory(audioCategory: AudioCategory): void {
+1 -1
src/App.native.tsx
··· 159 159 160 160 React.useEffect(() => { 161 161 PlatformInfo.setAudioCategory(AudioCategory.Ambient) 162 - PlatformInfo.setAudioMixWithOthers(true) 162 + PlatformInfo.setAudioActive(true) 163 163 initPersistedState().then(() => setReady(true)) 164 164 }, []) 165 165
+3 -3
src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
··· 60 60 nativeControls={true} 61 61 onEnterFullscreen={() => { 62 62 PlatformInfo.setAudioCategory(AudioCategory.Playback) 63 - PlatformInfo.setAudioMixWithOthers(false) 63 + PlatformInfo.setAudioActive(false) 64 64 player.muted = false 65 65 }} 66 66 onExitFullscreen={() => { 67 67 PlatformInfo.setAudioCategory(AudioCategory.Ambient) 68 - PlatformInfo.setAudioMixWithOthers(true) 68 + PlatformInfo.setAudioActive(true) 69 69 player.muted = true 70 70 if (!player.playing) player.play() 71 71 }} ··· 139 139 const category = muted ? AudioCategory.Ambient : AudioCategory.Playback 140 140 141 141 PlatformInfo.setAudioCategory(category) 142 - PlatformInfo.setAudioMixWithOthers(mix) 142 + PlatformInfo.setAudioActive(mix) 143 143 player.muted = muted 144 144 }, [player]) 145 145