Commit bc0784b1 authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

create function audioInit and checkPermission

parent 10763492
...@@ -16,7 +16,7 @@ const Stack = createNativeStackNavigator(); ...@@ -16,7 +16,7 @@ const Stack = createNativeStackNavigator();
const AppRouter = () => { const AppRouter = () => {
return ( return (
<NavigationContainer> <NavigationContainer>
<Stack.Navigator initialRouteName="Splash"> <Stack.Navigator initialRouteName="Color">
<Stack.Screen <Stack.Screen
options={{headerShown: false}} options={{headerShown: false}}
name="Home" name="Home"
......
...@@ -28,23 +28,59 @@ export default function Blue(color) { ...@@ -28,23 +28,59 @@ export default function Blue(color) {
const backColor = color.route.params.color; const backColor = color.route.params.color;
React.useEffect(() => { React.useEffect(() => {
audioInit();
const unsubscribe = navigation.addListener("focus", () => { const unsubscribe = navigation.addListener("focus", () => {
// The screen is focused // The screen is focused
// Call any action // Call any action
Orientation.unlockAllOrientations(); Orientation.unlockAllOrientations();
Orientation.lockToLandscape(); Orientation.lockToLandscape();
}); });
return unsubscribe; return unsubscribe;
}, [navigation]); }, [navigation]);
// audioInit
function audioInit() {
return( console.log('audioInit');
const colorAudio = {
sampleRate: 16000,
channels: 1,
bitsPerSample: 16,
wavFile: 'color.wav', // thise wave file name
};
AudioRecord.init(colorAudio);
}
// checkPermission
async function checkPermission() {
console.log('checkPermission');
const p = await Permissions.check('microphone');
console.log(p);
console.log('permission check', p);
if (p === 'authorized') {
console.log('if');
//audio start
audioStart();
} else {
console.log('else');
return requestPermission();
}
}
return (
<SafeAreaView> <SafeAreaView>
<View style={{flexDirection: "column"}}> <View style={{ flexDirection: "column" }}>
<ImageBackground style={styles.image} source={require("../../assets/game/gameback.png")}> <ImageBackground style={styles.image} source={require("../../assets/game/gameback.png")}>
<View> <View>
<View style={styles.textBody}> <View style={styles.textBody}>
<Text style={styles.text}>Say the name of this color?</Text> <Text style={styles.text}>Say the name of this color?</Text>
</View> </View>
...@@ -57,21 +93,21 @@ export default function Blue(color) { ...@@ -57,21 +93,21 @@ export default function Blue(color) {
<Image style={styles.blackboard} source={require("../../assets/game/blackboard.png")}></Image> <Image style={styles.blackboard} source={require("../../assets/game/blackboard.png")}></Image>
<View style={{width: 180, height: 180, backgroundColor: backColor, marginTop: -370, marginLeft: 455, borderRadius: 100}}> <View style={{ width: 180, height: 180, backgroundColor: backColor, marginTop: -370, marginLeft: 455, borderRadius: 100 }}>
</View> </View>
</View> </View>
<View style={{flexDirection: "row", marginLeft: 480}}> <View style={{ flexDirection: "row", marginLeft: 480 }}>
<Button style={styles.button} title="Recode"/> <Button style={styles.button} title="Recode" />
<Button title="Return" color="#1DCE92"/> <Button title="Return" color="#1DCE92" />
<Button title="Exit" color="#841584"/> <Button title="Exit" color="#841584" />
</View> </View>
</ImageBackground> </ImageBackground>
</View> </View>
</SafeAreaView> </SafeAreaView>
) )
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment