From 21e214c23579e5ca45fed3ec563d4010e37562a2 Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Wed, 14 Aug 2024 20:21:14 +0100
Subject: [Video] set audio category to ambient every time a new player is made
 (#4934)

* set auto category to ambient every time a new player is made

* mute on foregrounding

* remember previous state

---------

Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>
Co-authored-by: Hailey <me@haileyok.com>
---
 src/view/com/util/post-embeds/VideoPlayerContext.tsx | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/view/com/util/post-embeds/VideoPlayerContext.tsx')

diff --git a/src/view/com/util/post-embeds/VideoPlayerContext.tsx b/src/view/com/util/post-embeds/VideoPlayerContext.tsx
index 20ebb6d2f..95511099e 100644
--- a/src/view/com/util/post-embeds/VideoPlayerContext.tsx
+++ b/src/view/com/util/post-embeds/VideoPlayerContext.tsx
@@ -3,6 +3,10 @@ import type {VideoPlayer} from 'expo-video'
 import {useVideoPlayer as useExpoVideoPlayer} from 'expo-video'
 
 import {logger} from '#/logger'
+import {
+  AudioCategory,
+  PlatformInfo,
+} from '../../../../../modules/expo-bluesky-swiss-army'
 
 const VideoPlayerContext = React.createContext<VideoPlayer | null>(null)
 
@@ -16,6 +20,9 @@ export function VideoPlayerProvider({
   // eslint-disable-next-line @typescript-eslint/no-shadow
   const player = useExpoVideoPlayer(source, player => {
     try {
+      PlatformInfo.setAudioCategory(AudioCategory.Ambient)
+      PlatformInfo.setAudioActive(false)
+
       player.loop = true
       player.muted = true
       player.play()
-- 
cgit 1.4.1

