New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-sound

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-sound

React Native module for playing sound clips on iOS, Android, and Windows

  • 0.11.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
162K
decreased by-4.87%
Maintainers
4
Weekly downloads
 
Created

What is react-native-sound?

The react-native-sound package is a module for playing sound files in a React Native application. It supports various audio formats and provides functionalities for loading, playing, pausing, stopping, and looping sounds.

What are react-native-sound's main functionalities?

Loading a Sound File

This feature allows you to load a sound file from the app bundle or a specified path. The callback function handles any errors that occur during loading.

const Sound = require('react-native-sound');
const sound = new Sound('filename.mp3', Sound.MAIN_BUNDLE, (error) => {
  if (error) {
    console.log('Failed to load the sound', error);
    return;
  }
  console.log('Sound loaded successfully');
});

Playing a Sound

This feature allows you to play a loaded sound file. The callback function checks if the sound played successfully or if there were any errors during playback.

sound.play((success) => {
  if (success) {
    console.log('Sound played successfully');
  } else {
    console.log('Playback failed due to audio decoding errors');
  }
});

Pausing a Sound

This feature allows you to pause the currently playing sound. You can resume playback from the paused position later.

sound.pause();

Stopping a Sound

This feature allows you to stop the currently playing sound. The callback function confirms that the sound has been stopped.

sound.stop(() => {
  console.log('Sound stopped');
});

Looping a Sound

This feature allows you to loop a sound indefinitely. You can set the number of loops to any positive integer for a specific number of repetitions.

sound.setNumberOfLoops(-1);

Other packages similar to react-native-sound

Keywords

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc