Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load mp3 on iOS #12

Closed
jenbennings opened this issue Jan 16, 2016 · 4 comments
Closed

Unable to load mp3 on iOS #12

jenbennings opened this issue Jan 16, 2016 · 4 comments

Comments

@jenbennings
Copy link

Currently trying to load an mp3 from the root directory in my project but am being thrown this error in the react native debugger:

Object {code: 2003334207, message: "The operation couldn’t be completed. (OSStatus error 2003334207.)", nativeStackIOS: Array[16], domain: "NSOSStatusErrorDomain"}

How I'm currently attempting to use react-native-sound:

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  Image,
  TouchableHighlight,
  View,
} = React;

var Sound = require('react-native-sound');

var ding = new Sound('ding.mp3', Sound.MAIN_BUNDLE, (error) => {
  if (error) {
    console.log(error);
  }
});

var soundtest = React.createClass({
  _handleDing: function() {
    ding.play();
  },

  render: function() {
    return (
      <View style={styles.container}>
        <TouchableHighlight onPress={this._handleDing}>
          <View style={{width: 100, height: 100, padding: 20, backgroundColor: 'red', borderRadius: 50}}>
          </View>
        </TouchableHighlight>
      </View>
    );
  }
});

AppRegistry.registerComponent('soundtest', () => soundtest);

My guess is that this has something to do with the react native/ios file system. I've tried multiple mp3s so I'm relatively sure it's not to do with the file itself, but perhaps where I'm storing it. Right now it is in the root directory of my react native project (same as index.ios.js).

I'm running:

    "react-native": "^0.17.0",
    "react-native-sound": "^0.7.3"

Any ideas?

@zmxv
Copy link
Owner

zmxv commented Jan 17, 2016

It doesn't matter where you store the file as long as it's bundled with the app. Can you select the mp3 in XCode's project navigator and verify that the Target Membership list includes the main build target?

@jenbennings
Copy link
Author

Doesn't appear to be in there anywhere. Not terribly familiar with Xcode so apologies if this is a newbie error 🙏. I've got it in the root of the react folder as I'd like it to be available for both iOS + Android.

screen shot 2016-01-16 at 5 18 40 pm

Where it actually lives

screen shot 2016-01-16 at 5 23 07 pm

@jenbennings
Copy link
Author

Managed to get this working once I added the file manually to the Xcode project. Unless this should have been done automatically, it might be a good idea to update the readme with specific info for iOS (you mention where audio files for Android should go).

Thanks for your help!

@zmxv
Copy link
Owner

zmxv commented Jan 17, 2016

Thanks for the suggestion. I've updated README.md with more detailed instructions.

ohtangza pushed a commit to ohtangza/react-native-sound that referenced this issue Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants