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

react-native-sound在安卓下播放音频失败 #8

Open
rico-c opened this issue Nov 9, 2018 · 0 comments
Open

react-native-sound在安卓下播放音频失败 #8

rico-c opened this issue Nov 9, 2018 · 0 comments

Comments

@rico-c
Copy link
Owner

rico-c commented Nov 9, 2018

使用Github文档下的方式运行发现没有播放音乐成功。

尝试以下写法:

Sound.setCategory('Playback');
        var whoosh = new Sound('http://42.81.26.4/mp3.9ku.com/hot/2012/05-14/467165.mp3', Sound.MAIN_BUNDLE, (error) => {
            if (error) {
                console.log('failed to load the sound', error);
                return;
            }
            console.log('duration in seconds: ' + whoosh.getDuration() + 'number of channels: ' + whoosh.getNumberOfChannels());
            whoosh.play((success) => {
                if (success) {
                    console.log('successfully finished playing');
                } else {
                    console.log('playback failed due to audio decoding errors');
                    // reset the player to its uninitialized state (android only)
                    // this is the only option to recover after an error occured and use the player again
                    whoosh.reset();
                }
            });
        });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant