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

How to play sound that is not remote or bundled in assets #16

Open
smithaitufe opened this issue May 19, 2018 · 1 comment
Open

How to play sound that is not remote or bundled in assets #16

smithaitufe opened this issue May 19, 2018 · 1 comment

Comments

@smithaitufe
Copy link

smithaitufe commented May 19, 2018

Thanks so much for the React Native Sound package.

I have tested the package with remote files and required ones using require module. But my problem is playing a file that is not in the two categories above.

For example, I use react-native-document-picker which allows the user to select a file from the phone storage. I want to play that sound but I am not able.

Please what is the suggested way of dealing with sort like that?

        let callback = (error, sound) => {
            if (error) {
                console.log('failed to load the sound', error);
                return;
            }
            sound.play(() => {               
                sound.release();
            });
        }
        let soundFile = this.props.uri
        soundFile = require("../assets/audio/advertising.mp3") //working fine
        var sound = new Sound(soundFile, error => callback(error, sound));
        soundFile = "https://raw.githubusercontent.com/zmxv/react-native-sound-demo/master/frog.wav" //this working.
        var sound = new Sound(soundFile, "", error => callback(error, sound));
        soundFile=this.props.uri //not working. The uri is the location of the file selected by the user. Sample uri looks like "file://content://com.android.externalstorage.documents/document/300C-0FED%3AMusics%2FJWLibrary%2Fiacu_E_03.mp3"
        var sound = new Sound(soundFile, "", error => callback(error, sound));

Thank you for your prompt response

@taheroo
Copy link

taheroo commented Sep 8, 2021

Hey @smithaitufe
Did you find any solution ? I am stuck at this now

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