capacitor-community / capacitor-community/native-audio
Cannot play mp3 neither from the documents folder, nor as a base64 string
- Dominant language
- Java
- Stars
- 154
- Forks
- 78
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Is there any way to play mp3s written by the FileSystem plugin / base64 in memory? According to an older report it was possible in the following way, however i presume there might have been changes since.
**To Reproduce**
1. Write base64 mp3 data to documents folder
await Filesystem.writeFile({ path: fileName, data: base64Data.split(",")[1], directory: Directory.Data })
2. Get uri of mp3 in documents folder
let uri = await Filesystem.getUri({ directory: Directory.Data, path: fileName });
3. Preload mp3
const preloadRes = await NativeAudio.preload({
assetId: "test",
assetPath: uri.uri,
audioChannelNum: 1,
isUrl: true
});
4. App crashes with
file:///var/mobile/Containers/Data/Application/E407FE9D-3D44-446E-A002-F1A790E41221/Documents/test2.mp3
⚡️ To Native -> NativeAudio preload 59491661
CapacitorCommunityNativeAudio/Plugin.swift:233: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2023-11-19 19:38:21.772021+0700 App[660:33869] CapacitorCommunityNativeAudio/Plugin.swift:233: Fatal error: Unexpectedly found nil while unwrapping an Optional value
**Expected behavior**
The app plays the mp3 file
**Smartphone (please complete the following information):**
- Device: iPhone 11 Pro
- OS: iOS 16.4.1
- Capacitor Version: 5
Contributor guide
Assessment
This issue has not been assessed yet.