[英]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.我正在使用本机 CLI 处理 android 和 windows 的项目,我想在用户单击按钮时播放声音。 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 ;为此,我使用react-native-sound
作为最著名的库来在 react native 上播放声音,并且它支持 windows,正如他们在文档中所说的那样;
It works fine on android, but on Windows it produces an error:它在 android 上工作正常,但在 Windows 上它会产生错误:
var RNSound = require('react-native').NativeModules.RNSound;
var IsAndroid = RNSound.IsAndroid;
I've tried to log the require('react-native').NativeModules
but the `RNSound wasn't there.我尝试记录require('react-native').NativeModules
但 `RNSound 不存在。
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?有没有办法让它在 windows 上工作,或者可以建议一些其他方法来使用本机反应在 android 和 windows 上播放声音?
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,在搜索并寻求帮助后,我的队友Ahmed Shatat深入了解了他们的 Repo,发现一个分支在 windows、android 和 IOS 上运行良好,
in the package json it should look like在 package json 它应该看起来像
"react-native-sound": "zmxv/react-native-sound#731/head",
and it will work它会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.