react-native-sound: null is not an object (evaluating 'RNSound.IsAndroid')

🪲 Description

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

🪲 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.

🪲 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…

  • iOS
  • Android
  • Windows

Are you using…

  • React Native CLI (e.g. react-native run-android)
  • Expo
  • Other: (please specify)

Which versions are you using?

  • React Native Sound: 0.11.0
  • React Native: 0.60.5
  • Android: 9.0

Does the problem occur on…

  • Simulator
  • Device

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18

Most upvoted comments

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

@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