Closed bobbyrinaldy closed 1 year ago
Hi.. Same problem in Samsung S9+ Device.. sound.mp3 cannot play
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?
:beetle: 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'
:beetle: 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
andfile://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
also, i have try to add content:// like this :
content:///storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
andcontent://storage/emulated/0/Download/bf7befd8a3abf8aa0bad9d359214fd22.mp3
but nothing work above.
:beetle: Please post your code:
:bulb: 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?