Open calebeaires opened 8 years ago
@calebeaires I'm using 1.5.2
and it's working fine.
Still having an issue?
I can confirm this method works in NativeScript 3.4.0.
But it's the only method working for Android. See issue #11
I'm trying to use in NativeScript-Vue. So far, (with tns preview) Sounds folder is not being built into iOS platform bundle. So nativescript-sound can't find the sound file.
Hi - I'm getting Sound not initialized; file not found when I'm trying to initialise the sound using
var beep = sound.create("~/sounds/beep.mp3")
I've checked and the mp3 is in that folder. This is using Android and Nativescript Vue.
@JKcolab Did you see my comment above? Nativescript-vue doesn't automatically include folders like ~/sounds/.
Hi EdJones, it doesn't for Android either. I even put the file in the images folder and changed the line to
var beep = sound.create("~/images/beep.mp3")
but got the same error. Images in that folder do work however.
I hacked the sound-common.js script to show the path it was looking at and it's looking at
data/data/org.nativescript.[name of app]/files/app/images/beep.mp3 but the file isn't found there.
I've put the sound file in other areas, like the app folder (and appropriately changed the path in the command) but still no joy.
@EdJones @JKcolab
This might be a problem with webpack.config.js
. Webpack may not be packaging your sound files to the out director.
Look for this section in webpack.config.js
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin(
[
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.+(jpg|png)" } },
{ from: { glob: "assets/**/*" } },
],
{
ignore: [`${relative(appPath, appResourcesFullPath)}/**`]
}
)
Somebody found a fix already? I've tried the webpack thing but no success...
Hi @eltharynd I tried quickly @mudlabs suggestion (thank you) and I didn't get the error message :-) but the sound didn't still didn't work :-(.
I going to test a bit more thoroughly first.
If you don't get the "file not found" error, but you have no sound playing, maybe you are trying to play the sound before it has finished buffering. I've never had that problem on iOS, but Android seems to take a little longer to buffer.
@JKcolab and @eltharynd;
@eltharynd, After you tried the webpack
fix did you keep getting the error message "file not found" when you try to initialise it, or just no sound?
@mudlabs Yes, allowing it buffer time works. Thanks you for reminding me.
It seems that the plugin does not work with NativeScript 1.5. I put the "sounds" folder with the file on "app" folder, then used this code:
Its is not playing the sound!