diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 5c7a7ab0e4..a2cf1c61c0 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,8 @@ - - diff --git a/example/android/build.gradle b/example/android/build.gradle index df1ce4db3b..c83c9a0749 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { buildToolsVersion = "34.0.0" - minSdkVersion = 23 + minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "26.1.10909125" diff --git a/example/ios/VisionCameraExample.xcodeproj/project.pbxproj b/example/ios/VisionCameraExample.xcodeproj/project.pbxproj index 829ad9100d..8f5892d0c2 100644 --- a/example/ios/VisionCameraExample.xcodeproj/project.pbxproj +++ b/example/ios/VisionCameraExample.xcodeproj/project.pbxproj @@ -181,7 +181,6 @@ LastUpgradeCheck = 1250; TargetAttributes = { 13B07F861A680F5B00A75B9A = { - DevelopmentTeam = CJW62Q77E7; LastSwiftMigration = 1240; }; }; @@ -422,7 +421,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = CJW62Q77E7; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = VisionCameraExample/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Vision Camera"; @@ -455,7 +454,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = CJW62Q77E7; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = VisionCameraExample/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Vision Camera"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.photography"; diff --git a/example/src/CameraPage.tsx b/example/src/CameraPage.tsx index af65e71462..fc8cdc5ee3 100644 --- a/example/src/CameraPage.tsx +++ b/example/src/CameraPage.tsx @@ -1,22 +1,24 @@ import * as React from 'react' -import { useRef, useState, useCallback, useMemo } from 'react' +import { useRef, useState, useCallback, useMemo, useEffect } from 'react' import type { GestureResponderEvent } from 'react-native' import { StyleSheet, Text, View } from 'react-native' import type { PinchGestureHandlerGestureEvent } from 'react-native-gesture-handler' import { PinchGestureHandler, TapGestureHandler } from 'react-native-gesture-handler' import type { CameraProps, CameraRuntimeError, PhotoFile, VideoFile } from 'react-native-vision-camera' import { - runAtTargetFps, + useAudioInputDevices, useCameraDevice, useCameraFormat, - useFrameProcessor, useLocationPermission, useMicrophonePermission, + AudioInputLevel, + useFrameProcessor, + runAtTargetFps, } from 'react-native-vision-camera' import { Camera } from 'react-native-vision-camera' import { CONTENT_SPACING, CONTROL_BUTTON_SIZE, MAX_ZOOM_FACTOR, SAFE_AREA_PADDING, SCREEN_HEIGHT, SCREEN_WIDTH } from './Constants' import Reanimated, { Extrapolate, interpolate, useAnimatedGestureHandler, useAnimatedProps, useSharedValue } from 'react-native-reanimated' -import { useEffect } from 'react' + import { useIsForeground } from './hooks/useIsForeground' import { StatusBarBlurBackground } from './views/StatusBarBlurBackground' import { CaptureButton } from './views/CaptureButton' @@ -27,6 +29,7 @@ import type { Routes } from './Routes' import type { NativeStackScreenProps } from '@react-navigation/native-stack' import { useIsFocused } from '@react-navigation/core' import { usePreferredCameraDevice } from './hooks/usePreferredCameraDevice' +import { useSafeAreaInsets } from 'react-native-safe-area-context' import { examplePlugin } from './frame-processors/ExamplePlugin' import { exampleKotlinSwiftPlugin } from './frame-processors/ExampleKotlinSwiftPlugin' @@ -39,13 +42,15 @@ const SCALE_FULL_ZOOM = 3 type Props = NativeStackScreenProps export function CameraPage({ navigation }: Props): React.ReactElement { + const audioInputDevices = useAudioInputDevices() + const { bottom } = useSafeAreaInsets() + const [selectedMic, setSelectedMic] = useState(audioInputDevices[0]) const camera = useRef(null) const [isCameraInitialized, setIsCameraInitialized] = useState(false) const microphone = useMicrophonePermission() const location = useLocationPermission() const zoom = useSharedValue(1) const isPressingButton = useSharedValue(false) - // check if camera page is active const isFocussed = useIsFocused() const isForeground = useIsForeground() @@ -189,6 +194,16 @@ export function CameraPage({ navigation }: Props): React.ReactElement { }) }, []) + useEffect(() => { + AudioInputLevel.setPreferredAudioInputDevice(selectedMic?.uid) + const subscription = AudioInputLevel.addAudioLevelChangedListener((level) => { + console.log('Current Audio device level:', level) + }) + return () => { + subscription.remove() + } + }, [selectedMic?.uid]) + const videoHdr = format?.supportsVideoHdr && enableHdr const photoHdr = format?.supportsPhotoHdr && enableHdr && !videoHdr @@ -201,6 +216,7 @@ export function CameraPage({ navigation }: Props): React.ReactElement { + + {audioInputDevices.map((item, index) => ( + setSelectedMic(item)} style={styles.microphoneButton}> + + {item.portType} + + + ))} + ) } @@ -322,4 +347,18 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + microphoneContainer: { + position: 'absolute', + left: 12, + top: 100, + }, + microphoneButton: { + height: 48, + }, + microphoneButtonText: { + color: 'white', + }, + microphoneButtonSelectedText: { + color: 'blue', + }, }) diff --git a/package/android/build.gradle b/package/android/build.gradle index b1d9973d0b..fd51f8f2d4 100644 --- a/package/android/build.gradle +++ b/package/android/build.gradle @@ -121,7 +121,7 @@ android { } defaultConfig { - minSdkVersion safeExtGet("minSdkVersion", 21) + minSdkVersion safeExtGet("minSdkVersion", 24) compileSdkVersion safeExtGet("compileSdkVersion", 34) targetSdkVersion safeExtGet("targetSdkVersion", 34) versionCode 1 diff --git a/package/android/src/main/java/com/mrousavy/camera/core/CameraConfiguration.kt b/package/android/src/main/java/com/mrousavy/camera/core/CameraConfiguration.kt index f91ce830bb..bd9383ff25 100644 --- a/package/android/src/main/java/com/mrousavy/camera/core/CameraConfiguration.kt +++ b/package/android/src/main/java/com/mrousavy/camera/core/CameraConfiguration.kt @@ -13,8 +13,9 @@ import com.mrousavy.camera.core.types.VideoStabilizationMode data class CameraConfiguration( // Input var cameraId: String? = null, - // Outputs + + var audioInputDeviceUid: String? = null, var preview: Output = Output.Disabled.create(), var photo: Output = Output.Disabled.create(), var video: Output