zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 747 forks source link

Uncaught Error: Cannot read property 'IsAndroid' of null #832

Closed FroshYama closed 7 months ago

FroshYama commented 9 months ago

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"

Neumann-Valle commented 8 months ago

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

TreoMang commented 8 months ago

Please read README.md

cd android
./gradlew cleanBuildCache

or

cd android
./gradlew clean