zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.79k stars 748 forks source link

null is not an object (evaluating 'RNSound.IsAndroid') #618

Closed FatemeKhodayari closed 4 years ago

FatemeKhodayari commented 4 years ago

:beetle: Description

I tried installing and using this package for playing an audio file which I fetch from an API.

:beetle: What have you tried?

I followed the instructions in the wiki. I've installed the package using npm. I've also linked it using react-native link react-native-sound. It says that both Android and IOS modules have been linked. But then when I start the metro server and reload the app, everything crashes giving the error. I've also tried rebuilding the project but it doesn't work either.

:beetle: Please post your code:

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { View } from 'react-native';
import { Card, Image, Button } from 'react-native-elements';
import Sound from 'react-native-sound';

class Activity extends Component {

  playSound() {
    const track = new Sound(this.props.sound, null, (error) => {
      if (error)
        console.log("Can't play sound. ", e);
      else
        track.play();
    });
  }

  render(){
    return (
      <Card title={this.props.title}>
        <View style={{ flexDirection: 'row', justifyContent: 'space-between', paddingTop: 20 }}>
          <Image
            source={{ uri: this.props.questions[0].options[0].value.image }}
            style={{ width: 100, height: 100 }}
          />
          <Image
            source={{ uri: this.props.questions[0].options[1].value.image }}
            style={{ width: 100, height: 100 }}
          />
          <Image
            source={{ uri: this.props.questions[0].options[2].value.image }}
            style={{ width: 100, height: 100 }}
          />
        </View>
        <View style={{ alignItems: 'center' }}>
          <Button
            titleStyle={{ fontSize: 40, fontWeight: '700', padding: 50 }} 
            title={this.props.presentation}
            onPress={this.playSound}
          />
        </View>
      </Card>
    );
  }
}

const mapStateToProps = (state) => {
  const { presentation, sound, title, questions } = state.game;
  return { presentation, sound, title, questions };
};

export default connect(mapStateToProps, {})(Activity);

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

rafaelvinicius commented 4 years ago

Same to me. IOS only. Android works fine.

rafaelvinicius commented 4 years ago

@FatemeKhodayari Look this: https://github.com/zmxv/react-native-sound/issues/215#issuecomment-510543679

Running pod install Deleting ios/build Running react-native run-ios

FatemeKhodayari commented 4 years ago

@FatemeKhodayari Look this: #215 (comment)

Running pod install Deleting ios/build Running react-native run-ios

I think this may work for IOS. But my problem is with Android only. :)

FatemeKhodayari commented 4 years ago

As far as I tried, there's no need to do the react-native link react-native-sound step. React Native does it automatically. No need to follow the instructions in wiki. Just rebuild the app and reload it. Everything works fine.

AdamGerthel commented 4 years ago

I have the same problem. Just installed react-native-sound and I'm getting this error in Android emulator. I've checked the linking (compared to manual steps) and everything looks in order.

vaidis commented 4 years ago

same here on linux / expo. The strange thinig is that the same problem occurs also with other libraries like react-native-track-player. Is it possible that react native is responsible for this fault?

Cat107 commented 4 years ago

Same problem, not working on iOS expo app

AdamGerthel commented 4 years ago

@Cat107 Libraries which require linking will never work with an Expo app, unless you're using the bare workflow. See https://docs.expo.io/introduction/why-not-expo/

beingArkReal commented 4 years ago

I'm facing exactly the same issue on an ios device, why is this closed what should i do?

markdashi commented 4 years ago

I'm facing exactly the same issue on an ios device, why is this closed what should i do?

try react-native link react-native-sound

hewang42 commented 3 years ago

Same problem, not working on iOS expo app @Cat107 I tried to replace with import {Audio} from 'expo-av' the error gone but there is no sound still

0xPratik commented 2 years ago

I am facing the same issue for both in IOS and android emulator

faizkhan7896 commented 1 year ago
react-native link react-native-sound

it's Working

markdashi commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

faizkhan7896 commented 1 year ago

Please write in english

markdashi commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

littlecorsican commented 1 year ago

its an auto reply, saying he is on vacation and cant reply