You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, im trying to play mp3 from physical device (Real Device). the code working for IOS but on ANDROID it says 'Resource not found : error code -1'
馃 What have you tried?
the file path is like this : /storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
i have try to add file:// like this : file:///storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
and file://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
also, i have try to add content:// like this : content:///storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
and content://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
but nothing work above.
馃 Please post your code:
play=asyncpath=>{letdirs=RNFetchBlob.fs.dirs;varpathFile=Platform.select({ios: dirs.DocumentDir,android: dirs.DownloadDir,});if(this.sound){this.sound.play(this.playComplete);this.setState({playState: 'playing'});}else{//constfilepath=pathFile+'/'+path.filename;this.sound=newSound(filepath,null,error=>{if(error){console.log('failed to load the sound',error);Alert.alert('Notice','audio file error. (Error code : 1)');this.setState({playState: 'paused'});}else{this.setState({playState: 'playing',duration: this.sound.getDuration(),});this.sound.play(this.playComplete);}});}};
my friends.. my solution was put the code into mountcomponent..
constructor(props) {
super(props);
this.state = {
};
sound = null
}
componentDidMount =() => {
this.sound = new Sound('mysound.mp3', Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
});
}
and then turn on when you want....
this.sound.play();
Note: Android: Save your sound clip files under the directory android/app/src/main/res/raw. Note that files in this directory must be lowercase and underscored (e.g. my_file_name.mp3) and that subdirectories are not supported by Android.
my friends.. my solution was put the code into mountcomponent..
constructor(props) {
super(props);
this.state = {
};
sound = null
}
componentDidMount =() => {
this.sound = new Sound('mysound.mp3', Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
});
}
and then turn on when you want.... this.sound.play();
Note: Android: Save your sound clip files under the directory android/app/src/main/res/raw. Note that files in this directory must be lowercase and underscored (e.g. my_file_name.mp3) and that subdirectories are not supported by Android.
What if We need to access the Download Directory? Fetch from Director and play? Could please provide any solution for this scenario?
馃 Description
Hello, im trying to play mp3 from physical device (Real Device). the code working for IOS but on ANDROID it says 'Resource not found : error code -1'
馃 What have you tried?
the file path is like this :
/storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
i have try to add file:// like this :
file:///storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
and
file://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
also, i have try to add content:// like this :
content:///storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
and
content://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
but nothing work above.
馃 Please post your code:
馃挕 Possible solution
Is your issue with...
Are you using...
react-native run-android
)Which versions are you using?
Does the problem occur on...
If your problem is happening on a device, which device?
The text was updated successfully, but these errors were encountered: