expo keep awake
This commit is contained in:
+2
-1
@@ -53,6 +53,7 @@
|
|||||||
"expo-image": "~2.0.7",
|
"expo-image": "~2.0.7",
|
||||||
"expo-image-picker": "~16.0.6",
|
"expo-image-picker": "~16.0.6",
|
||||||
"expo-insights": "~0.8.2",
|
"expo-insights": "~0.8.2",
|
||||||
|
"expo-keep-awake": "^15.0.8",
|
||||||
"expo-linear-gradient": "~14.0.2",
|
"expo-linear-gradient": "~14.0.2",
|
||||||
"expo-linking": "~7.0.5",
|
"expo-linking": "~7.0.5",
|
||||||
"expo-location": "~18.0.10",
|
"expo-location": "~18.0.10",
|
||||||
@@ -133,4 +134,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useFocusEffect } from '@react-navigation/native'
|
import { useFocusEffect } from '@react-navigation/native'
|
||||||
import { CameraView, useCameraPermissions } from 'expo-camera'
|
import { CameraView, useCameraPermissions } from 'expo-camera'
|
||||||
|
import { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake'
|
||||||
import * as FileSystem from 'expo-file-system'
|
import * as FileSystem from 'expo-file-system'
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { BackHandler, Text, TouchableOpacity, View } from 'react-native'
|
import { BackHandler, Text, TouchableOpacity, View } from 'react-native'
|
||||||
@@ -22,6 +23,7 @@ import CreateLyricsHeader from '../Writing/components/CreateLyricsHeader'
|
|||||||
const TIME_BEFORE_INCREMENT_MS = 20000 // 20s
|
const TIME_BEFORE_INCREMENT_MS = 20000 // 20s
|
||||||
const COUNTDOWN_SECONDS = 10
|
const COUNTDOWN_SECONDS = 10
|
||||||
const LOG_PREFIX = '[RecordPlayback]'
|
const LOG_PREFIX = '[RecordPlayback]'
|
||||||
|
const KEEP_AWAKE_TAG = 'record-playback'
|
||||||
const log =
|
const log =
|
||||||
typeof __DEV__ === 'undefined' || __DEV__
|
typeof __DEV__ === 'undefined' || __DEV__
|
||||||
? (...args) => console.log(LOG_PREFIX, ...args)
|
? (...args) => console.log(LOG_PREFIX, ...args)
|
||||||
@@ -97,6 +99,25 @@ const RecordPlayback = ({ route }) => {
|
|||||||
isPausedRef.current = isPaused
|
isPausedRef.current = isPaused
|
||||||
}, [isPaused])
|
}, [isPaused])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const shouldKeepAwake = isPreparing || isRecording
|
||||||
|
const updateKeepAwake = async () => {
|
||||||
|
try {
|
||||||
|
if (shouldKeepAwake) {
|
||||||
|
await activateKeepAwakeAsync(KEEP_AWAKE_TAG)
|
||||||
|
} else {
|
||||||
|
await deactivateKeepAwake(KEEP_AWAKE_TAG)
|
||||||
|
}
|
||||||
|
} catch (_) { }
|
||||||
|
}
|
||||||
|
void updateKeepAwake()
|
||||||
|
return () => {
|
||||||
|
try {
|
||||||
|
void deactivateKeepAwake(KEEP_AWAKE_TAG)
|
||||||
|
} catch (_) { }
|
||||||
|
}
|
||||||
|
}, [isPreparing, isRecording])
|
||||||
|
|
||||||
// Removed AppState listener as it was too aggressive.
|
// Removed AppState listener as it was too aggressive.
|
||||||
// We now use duration validation at the end of recording.
|
// We now use duration validation at the end of recording.
|
||||||
|
|
||||||
|
|||||||
@@ -5234,6 +5234,11 @@ expo-json-utils@~0.14.0:
|
|||||||
resolved "https://registry.npmjs.org/expo-json-utils/-/expo-json-utils-0.14.0.tgz"
|
resolved "https://registry.npmjs.org/expo-json-utils/-/expo-json-utils-0.14.0.tgz"
|
||||||
integrity sha512-xjGfK9dL0B1wLnOqNkX0jM9p48Y0I5xEPzHude28LY67UmamUyAACkqhZGaPClyPNfdzczk7Ej6WaRMT3HfXvw==
|
integrity sha512-xjGfK9dL0B1wLnOqNkX0jM9p48Y0I5xEPzHude28LY67UmamUyAACkqhZGaPClyPNfdzczk7Ej6WaRMT3HfXvw==
|
||||||
|
|
||||||
|
expo-keep-awake@^15.0.8:
|
||||||
|
version "15.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-15.0.8.tgz#911c5effeba9baff2ccde79ef0ff5bf856215f8d"
|
||||||
|
integrity sha512-YK9M1VrnoH1vLJiQzChZgzDvVimVoriibiDIFLbQMpjYBnvyfUeHJcin/Gx1a+XgupNXy92EQJLgI/9ZuXajYQ==
|
||||||
|
|
||||||
expo-keep-awake@~14.0.3:
|
expo-keep-awake@~14.0.3:
|
||||||
version "14.0.3"
|
version "14.0.3"
|
||||||
resolved "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-14.0.3.tgz"
|
resolved "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-14.0.3.tgz"
|
||||||
|
|||||||
Reference in New Issue
Block a user