-
Notifications
You must be signed in to change notification settings - Fork 104
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
Can not play audio from App folder #131
Comments
Having same issue. Can play from URL, but not from local file.
|
Only time I've had this issue is when the file type isn't supported on the device. Can you share the file you're trying to use? The demo app works fine with a local .mp3 seen here |
I tried using the @bradmartin are you using |
@dodas I have solved: please put and rename mp3 or m4a file with .png ext, it will be work, look above how I implemented, player |
Follow-up: using the plugin+NS Angular+iOS, I also have only been able to get a local file to play if I have .png at the end of it, like:
Previously, mySound ended in mp3 and played fine with prior NS versions. Since upgrading to NS 5.0+, it stopped working, and would give error: It now works with the .png at the end. This seems odd, because I had thought png was an image file. How could it play audio? |
Same issue here on both iOS and Android using Nativescript-Vue. The workaround to use png (and jpg for that matter) indeed works for wav/mp3 and m4a (iOS) files, my uneducated guess is that the os helps identifying the type of the file then. |
Renaming to .png didn't work for me. Playing from Url does work. |
I was able to diagnose this slightly by determining that for some reason the nativescript filesystem could not see my sounds folder that existed inside of the app folder. I don't think there was anything special about the permissions but it could see my images folder, so I tried moving my audio into there and playFromFile still failed. So I instead moved all of my mp3 audio files into the assets folder which the nativescript filesystem could see and they were suddenly able to play again without the setDataSource failure. To diagnose this I hacked the reslveAudioFilePath in nativescript-audio/common.js to determine if nativescript could see the various file folders and files.
You could if you were desperate try copying this code into your common.js
It might make sense to add an additional level of error checking somewhere in the nativescript-audio app to provide a better error to people so that they are aware the problem is nativescript can't see the files vs. the issue being with underlying android audio. I also don't have any idea why assets works and sounds doesn't. Is there some kind of underlying pre-approved folders that nativescript has accesss too ? I'm using vue-nativescript and this all changed with the upgrade so I had to spend hours rebuilding my app to get it working again so now I can resume actual development. |
Try to add to Info.plist this:
|
In my case it was related with webpack |
This fixed it for me. Thanks so much! My particular solution was just adding the new folder I had created with my audio files, new CopyWebpackPlugin([
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.+(jpg|png)" } },
{ from: { glob: "assets/**/*" } },
{ from: { glob: "media/**/*" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), |
.initFromFile({
audioFile: '~/resources/sample.mp3',
loop: false,
completeCallback: console.log('reference back to player:', player),
errorCallback: console.log('the error:', player),
})
Vue.js is the framework being used.
I noticed there was a closed issue like this one, but I didn't see the answer there
#126
Thanks in advance.
The text was updated successfully, but these errors were encountered: