zmxv / react-native-sound

React Native module for playing sound clips

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught Error: Cannot read property 'IsAndroid' of null

FroshYama opened this issue · comments

import React, { useState, useEffect } from 'react';
import { Image, View, TouchableOpacity, StyleSheet, Text, Pressable, ScrollView, Modal } from 'react-native';
import Sound from 'react-native-sound';
import HapticFeedback from 'react-native-haptic-feedback';

const Order2 = ({ navigation }) => {
const [quantity, setQuantity] = useState(1);
const [modalVisible, setModalVisible] = useState(false);
const [modalContainer2Visible, setModalContainer2Visible] = useState(false);

useEffect(() => {
    // Show a message when navigating to this screen
    setModalContainer2Visible(true);

    // Hide the message after 3000 milliseconds (3 seconds)
    setTimeout(() => {
        setModalContainer2Visible(false);
    }, 5000);
}, []);

const incrementQuantity = () => {
    setQuantity(prevQuantity => Math.min(prevQuantity + 1, 10));
};

const decrementQuantity = () => {
    setQuantity(prevQuantity => Math.max(prevQuantity - 1, 1));
};

const handleReferButtonPress = () => {
    setModalVisible(!modalVisible);
};

// const completedSound = new Sound('../assets/audio/completed.wav', Sound.MAIN_BUNDLE, (error) => {
//     if (error) {
//       console.log('Failed to load the sound', error);
//     }
// });


//   useEffect(() => {
//     // Show a message when navigating to this screen
//     setModalContainer2Visible(true);
  
//     completedSound.play(); 
//     HapticFeedback.trigger('impactHeavy'); 
  
//     // Hide the message after 3000 milliseconds (3 seconds)
//     setTimeout(() => {
//       setModalContainer2Visible(false);
//     }, 5000);
//   }, []);

My package.json:
"react-native-gesture-handler": "^2.13.1",
"react-native-gifted-chat": "^0.0.5",
"react-native-haptic-feedback": "^2.2.0",
"react-native-image-picker": "^7.0.0",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-lightbox": "^0.8.1",
"react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-snap-carousel": "^4.0.0-beta.6",
"react-native-sound": "^0.11.2",
"react-native-svg": "^13.13.0",
"react-native-swiper": "^1.6.0",
"react-navigation": "^4.4.4"

Same is happening to me, won't work with EXPO.
Ejecting works fine, expo run:android

Please read README.md

cd android
./gradlew cleanBuildCache

or

cd android
./gradlew clean