简体   繁体   English

反应本机声音不适用于 Windows:无法读取未定义的属性“IsAndroid”

[英]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.

相关问题 反应本机“无法读取未定义的属性” AsyncStorage - React native 'Cannot read property of undefined' AsyncStorage React Native无法读取属性未定义错误 - React Native cannot read property undefined error React Native 无法读取未定义的属性“导航” - React Native Cannot read property 'navigate' of undefined 无法读取属性 '#<webview> ' 未定义的反应本机</webview> - Cannot read property '#<WebView>' of undefined react native 反应本机如何处理无法读取未定义的属性“未定义” - react native how to deal with Cannot read property 'undefined' of undefined 无法读取未定义的属性“导航” - React Native Navigation - Cannot read property 'navigate' of undefined - React Native Navigation react-native-google-signin-无法读取未定义的属性&#39;number&#39; - React-native-google-signin - Cannot read property 'number' of undefined 类型错误:无法读取 React Native 中未定义的属性“set” - TypeError: Cannot read property 'set' of undefined in React native 无法读取未定义的属性&#39;initSdk&#39; - Appsflyer集成React Native - Cannot read property 'initSdk' of undefined - Appsflyer integration React Native React-Native Navigator:无法读取未定义的属性“ push” - React-Native Navigator: Cannot read property 'push' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM