nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

How to use with webpack enabled? #97

Closed SamuelM333 closed 6 years ago

SamuelM333 commented 6 years ago

I have webpack enabled on my project and I cannot init a player from a file. I guess webpack is changing the location of the file.

I'm writing the directory like the readme says: ~/audio/song.mp3

I ran the app without webpack and works just fine.

I'm using nativescript-audio@4.3.3 and nativescript-dev-webpack@0.9.1

Any ideas? Thanks.

bradmartin commented 6 years ago

Sorry, I haven't done much with webpack and NS. You might have some better luck on the NS Slack, I see lots of people are using webpack and someone might be more familiar than I am with what's happening.

SamuelM333 commented 6 years ago

Ok, I'll give it a try on NS Slack. If I find anything I'll post it here. Thanks.

SamuelM333 commented 6 years ago

I got help from the NS Slack. You just need to add the audio files to your webpack.config.js file, like this:

// inside the plugins array

new CopyWebpackPlugin([
    { from: "App_Resources/**" },
    { from: "fonts/**" },
    { from: "**/*.jpg" },
    { from: "**/*.png" },
    { from: "**/*.xml" },
    { from: "audio/*.mp3" }, // add this line (or the directory where the audio files are)
]),

Here's a full example: https://github.com/EddyVerbruggen/nativescript-pluginshowcase/blob/6d5bde22cd9b50e8ca6872c9d89788d4f682100a/webpack.config.js#L107

szgozcan commented 5 years ago

I went through the same problem with webpack enabled and the solution worked for me either. Thank you