Search code examples
javascriptreactjsreact-nativereact-native-soundreact-native-windows

react native sound Not working on Windows: Cannot read property 'IsAndroid' of undefined


I'm working on project for android and windows using react native CLI and I want to play sound when the user clicks a butto. For that, I've used react-native-sound as the most famous library to play sounds on react native and the it supports windows as they say on their docs;

It works fine on android, but on Windows it produces an error:

var RNSound = require('react-native').NativeModules.RNSound;
var IsAndroid = RNSound.IsAndroid;

enter image description here

I've tried to log the require('react-native').NativeModules but the `RNSound wasn't there.

Is there any way to make it work on windows or can suggest some other way to play sounds on both android and windows using react native?


Solution

  • after searching and asking for help my teammate Ahmed Shatat have a deep look into their Repo and find a branch works fine on windows, android and IOS,

    in the package json it should look like

    "react-native-sound": "zmxv/react-native-sound#731/head",
    

    and it will work