feat: add alert sound for timer and time-until done
All checks were successful
Pull Request Check / validate (pull_request) Successful in 28s
All checks were successful
Pull Request Check / validate (pull_request) Successful in 28s
This commit is contained in:
18
App.js
18
App.js
@@ -3,6 +3,7 @@ import { BackHandler, Platform, StatusBar, Modal, View, Image, StyleSheet, Butto
|
||||
import * as ScreenOrientation from 'expo-screen-orientation';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
import { Accelerometer } from 'expo-sensors';
|
||||
import { Audio } from 'expo-av';
|
||||
import FocusScreen from './src/screens/FocusScreen';
|
||||
import HomeScreen from './src/screens/HomeScreen';
|
||||
import TimeUntilScreen from './src/screens/TimeUntilScreen';
|
||||
@@ -194,6 +195,23 @@ export default function App() {
|
||||
const timerSec = timerRemaining % 60;
|
||||
const tuCountdown = getTuCountdown();
|
||||
|
||||
const playSound = async () => {
|
||||
try {
|
||||
const { sound } = await Audio.Sound.createAsync(
|
||||
{ uri: 'https://shx.reversed.dev/u/mCgT76.mp3' },
|
||||
{ shouldPlay: true, volume: 1.0 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.log('Error playing sound:', error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (timerDone || tuIsOver) {
|
||||
playSound();
|
||||
}
|
||||
}, [timerDone, tuIsOver]);
|
||||
|
||||
if (focusMode) {
|
||||
return (
|
||||
<FocusScreen
|
||||
|
||||
Reference in New Issue
Block a user