{"id":4650,"url":"https://github.com/zmxv/react-native-sound","last_synced_at":"2025-05-14T12:06:36.158Z","repository":{"id":1768610,"uuid":"44515034","full_name":"zmxv/react-native-sound","owner":"zmxv","description":"React Native module for playing sound clips","archived":false,"fork":false,"pushed_at":"2025-05-06T06:58:18.000Z","size":689,"stargazers_count":2827,"open_issues_count":346,"forks_count":760,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-05-07T11:41:40.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zmxv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-10-19T06:22:23.000Z","updated_at":"2025-05-07T09:51:58.000Z","dependencies_parsed_at":"2023-07-05T16:00:45.290Z","dependency_job_id":"881d7105-4945-47d0-84a7-3170e5345106","html_url":"https://github.com/zmxv/react-native-sound","commit_stats":{"total_commits":217,"total_committers":101,"mean_commits":"2.1485148514851486","dds":0.8248847926267281,"last_synced_commit":"46117dbb2ef6131269a806142d81615133968309"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmxv%2Freact-native-sound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmxv%2Freact-native-sound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmxv%2Freact-native-sound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmxv%2Freact-native-sound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmxv","download_url":"https://codeload.github.com/zmxv/react-native-sound/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140739,"owners_count":22021218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:19.055Z","updated_at":"2025-05-14T12:06:36.107Z","avatar_url":"https://github.com/zmxv.png","language":"Kotlin","readme":"# react-native-sound\n\n[![](https://img.shields.io/npm/v/react-native-sound.svg?style=flat-square)][npm]\n[![](https://img.shields.io/npm/l/react-native-sound.svg?style=flat-square)][npm]\n[![](https://img.shields.io/npm/dm/react-native-sound.svg?style=flat-square)][npm]\n\n[npm]: https://www.npmjs.com/package/react-native-sound\n\nReact Native module for playing sound clips on iOS, Android, and Windows.\n\nBe warned, this software is alpha quality and may have bugs. Test on your own\nand use at your own risk!\n\n## Feature matrix\n\nReact-native-sound does not support streaming. See [#353][] for more info.\nOf course, we would welcome a PR if someone wants to take this on.\n\nIn iOS, the library uses [AVAudioPlayer][], not [AVPlayer][].\n\n[#353]: https://github.com/zmxv/react-native-sound/issues/353\n[AVAudioPlayer]: https://developer.apple.com/documentation/avfoundation/avaudioplayer\n[AVPlayer]: https://developer.apple.com/documentation/avfoundation/avplayer\n\nFeature | iOS | Android | Windows\n---|---|---|---\nLoad sound from the app bundle | ✓ | ✓ | ✓\nLoad sound from other directories | ✓ | ✓ | ✓\nLoad sound from the network | ✓ | ✓ |\nPlay sound | ✓ | ✓ | ✓\nPlayback completion callback | ✓ | ✓ | ✓\nPause | ✓ | ✓ | ✓\nResume | ✓ | ✓ | ✓\nStop | ✓ | ✓ | ✓\nReset |  | ✓ |\nRelease resource | ✓ | ✓ | ✓\nGet duration | ✓ | ✓ | ✓\nGet number of channels | ✓ |   |\nGet/set volume | ✓ | ✓ | ✓\nGet system volume | ✓ | ✓ |\nSet system volume |   | ✓ |\nGet/set pan | ✓ |   |\nGet/set loops | ✓ | ✓ | ✓\nGet/set exact loop count | ✓ |   |\nGet/set current time | ✓ | ✓ | ✓\nSet speed | ✓ | ✓ |\n\n## Installation\n\nFirst install the npm package from your app directory:\n\n```javascript\nnpm install react-native-sound --save\n```\nNote: If your react-native version is \u003e= 0.60 then linking is done automatically.\n\nIf your react-native version is \u003c 0.60 then link it using:\n\n```javascript\nreact-native link react-native-sound\n```\n\n**If you encounter this error**\n\n```\nundefined is not an object (evaluating 'RNSound.IsAndroid')\n```\n\nyou may additionally need to fully clear your build caches for Android. You\ncan do this using\n\n```bash\ncd android\n./gradlew cleanBuildCache\n```\n\nAfter clearing your build cache, you should execute a new `react-native` build.\n\nIf you still experience issues, **know that this is the most common build issue.** See [#592][] and the several\nissues linked from it for possible resolution. A pull request with improved\ndocumentation on this would be welcome!\n\n[#592]: https://github.com/zmxv/react-native-sound/issues/592\n\n### Manual Installation Notes\n\nPlease see the Wiki for these details https://github.com/zmxv/react-native-sound/wiki/Installation\n\n\n## Help with React-Native-Sound\n\n* For react-native-sound developers  [![][gitter badge]](https://gitter.im/react-native-sound/developers)\n* For help using react-native-sound  [![][gitter badge]](https://gitter.im/react-native-sound/Help)\n\n[gitter badge]: https://img.shields.io/gitter/room/react-native-sound/developers.svg?format=flat-square\n\n## Demo project\n\nhttps://github.com/zmxv/react-native-sound-demo\n\n## Player\n\n\u003cimg src=\"https://github.com/benevbright/react-native-sound-playerview/blob/master/docs/demo.gif?raw=true\"\u003e\n\nhttps://github.com/benevbright/react-native-sound-playerview\n\n## Basic usage\n\nFirst you'll need to add audio files to your project.\n\n- Android: Save your sound clip files under the directory `android/app/src/main/res/raw`. Note that files in this directory must be lowercase and underscored (e.g. my_file_name.mp3) and that subdirectories are not supported by Android.\n- iOS: Open Xcode and add your sound files to the project (Right-click the project and select `Add Files to [PROJECTNAME]`)\n\n```js\n// Import the react-native-sound module\nvar Sound = require('react-native-sound');\n\n// Enable playback in silence mode\nSound.setCategory('Playback');\n\n// Load the sound file 'whoosh.mp3' from the app bundle\n// See notes below about preloading sounds within initialization code below.\nvar whoosh = new Sound('whoosh.mp3', Sound.MAIN_BUNDLE, (error) =\u003e {\n  if (error) {\n    console.log('failed to load the sound', error);\n    return;\n  }\n  // loaded successfully\n  console.log('duration in seconds: ' + whoosh.getDuration() + 'number of channels: ' + whoosh.getNumberOfChannels());\n\n  // Play the sound with an onEnd callback\n  whoosh.play((success) =\u003e {\n    if (success) {\n      console.log('successfully finished playing');\n    } else {\n      console.log('playback failed due to audio decoding errors');\n    }\n  });\n});\n\n// Reduce the volume by half\nwhoosh.setVolume(0.5);\n\n// Position the sound to the full right in a stereo field\nwhoosh.setPan(1);\n\n// Loop indefinitely until stop() is called\nwhoosh.setNumberOfLoops(-1);\n\n// Get properties of the player instance\nconsole.log('volume: ' + whoosh.getVolume());\nconsole.log('pan: ' + whoosh.getPan());\nconsole.log('loops: ' + whoosh.getNumberOfLoops());\n\n// Seek to a specific point in seconds\nwhoosh.setCurrentTime(2.5);\n\n// Get the current playback point in seconds\nwhoosh.getCurrentTime((seconds) =\u003e console.log('at ' + seconds));\n\n// Pause the sound\nwhoosh.pause();\n\n// Stop the sound and rewind to the beginning\nwhoosh.stop(() =\u003e {\n  // Note: If you want to play a sound after stopping and rewinding it,\n  // it is important to call play() in a callback.\n  whoosh.play();\n});\n\n// Release the audio player resource\nwhoosh.release();\n```\n\n## Notes\n\n- To minimize playback delay, you may want to preload a sound file without calling `play()` (e.g. `var s = new Sound(...);`) during app initialization. This also helps avoid a race condition where `play()` may be called before loading of the sound is complete, which results in no sound but no error because loading is still being processed.\n- You can play multiple sound files at the same time. Under the hood, this module uses `AVAudioSessionCategoryAmbient` to mix sounds on iOS.\n- You may reuse a `Sound` instance for multiple playbacks.\n- On iOS, the module wraps `AVAudioPlayer` that supports aac, aiff, mp3, wav etc. The full list of supported formats can be found at https://developer.apple.com/library/content/documentation/MusicAudio/Conceptual/CoreAudioOverview/SupportedAudioFormatsMacOSX/SupportedAudioFormatsMacOSX.html\n- On Android, the module wraps `android.media.MediaPlayer`. The full list of supported formats can be found at https://developer.android.com/guide/topics/media/media-formats.html\n- On Android, the absolute path can start with '/sdcard/'. So, if you want to access a sound called \"my_sound.mp3\" on Downloads folder, the absolute path will be: '/sdcard/Downloads/my_sound.mp3'.\n- You may chain non-getter calls, for example, `sound.setVolume(.5).setPan(.5).play()`.\n\n## Audio on React Native\n\n- [The State of Audio Libraries in React Native (Oct. 2018)][medium]\n- [react-native-audio-toolkit][]\n- [react-native-video][] (also plays audio)\n- [Expo Audio SDK][]\n- [#media on awesome-react-native][#media]\n\n[medium]: https://medium.com/@emmettharper/the-state-of-audio-libraries-in-react-native-7e542f57b3b4\n[react-native-audio-toolkit]: https://github.com/react-native-community/react-native-audio-toolkit\n[react-native-video]: https://github.com/react-native-community/react-native-video\n[expo audio sdk]: https://docs.expo.io/versions/latest/sdk/audio/\n[#media]: http://www.awesome-react-native.com/#media\n\n## Contributing\n\nPull requests welcome with bug fixes, documentation improvements, and\nenhancements.\n\nWhen making big changes, please open an issue first to discuss.\n\n## License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":["Components","\u003ca name=\"Image-\u0026-Audio-\u0026-Video-\u0026-Docs:-Native-Modules\"\u003eImage, Audio, Video \u0026 Docs: Native Modules\u003c/a\u003e","Programming Languages","TypeScript","React Native Project Showcase"],"sub_categories":["Media","Javascript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmxv%2Freact-native-sound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmxv%2Freact-native-sound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmxv%2Freact-native-sound/lists"}