Code Monkey home page Code Monkey logo

Comments (4)

nu5rim3 avatar nu5rim3 commented on July 30, 2024 1

how to play downloaded sound files. am looking for a solution for the same problem.

from react-native-sound-player.

johnsonsu avatar johnsonsu commented on July 30, 2024

Hi, sorry about the late reply, did you manage to solve this problem? I can take a look into it if needed.

from react-native-sound-player.

istvan-szilagyi avatar istvan-szilagyi commented on July 30, 2024

Well it seems you're a bit confused with the directories :)

  1. Main Bundle: this directory is read-only, so you CAN'T download files here within the application, you can see only files that you have builded into the bundle.
  2. Documents directory: this directory has read-write permissions. As I can see in your path, you have downloaded the file into this directory. The command SoundPlayer.playSoundFile can play only files from the bundle, and not Documents directory. This is the code in the Xcode project:
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:name ofType:type];

Actually I could make it run from documents, but you will have to edit the Xcode project of this module:

  1. Open the Xcode project
  2. Open RNSoundPlayer.m
  3. Find function: RCT_EXPORT_METHOD(playUrl:(NSString *)url)
  4. After line: NSURL *soundURL = [NSURL URLWithString:url]; add the following:
if (soundURL == nil) {
   soundURL = [NSURL fileURLWithPath:url]; 
}
if (soundURL == nil) {
   return;
}

Now just call (from the React project):
SoundPlayer.playUrl('/Library/Developer/CoreSimulator/...<your path to the file>');

Cheers!

from react-native-sound-player.

johnsonsu avatar johnsonsu commented on July 30, 2024

This should be resolved by #37, thanks to @assertchris.

from react-native-sound-player.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.