Thank you for your patience. I investigated this a bit further. The NativeScript-Sound
module uses SoundPool
to play a sound on Android. This imposes a few limitations on the app:
- SoundPool decompresses the loaded audio to 16-bit PCM mono or stereo stream and that takes a certain amount of time, depending on the size of sound file. This is why if you try to play the sound before that process is over, an error "sample x not ready" is thrown. Read more here and here.
- SoundPool seems to be designed to play short sound effects which is why if you play a larger file, it would only play about 5 seconds of it. Read more here and here.
If you have to play a longer or larger file, I would recommend that you use an older version of the module where the Android
implementation uses MediaPlayer
As for deploying the file on the device, I am not sure why you believe the file is not loaded on the device. When you add the audio file under the app
folder in the Project Navigator
, then it is deployed on the device along with the entire content of the app. However, as the sound file is part of the application package you can't actually see it on a non-rooted Android device.
Since you submitted this ticket under the Telerik Platform
product line, I've prepared a sample NativeScript
app built in Telerik Platform
that demonstrates the usage of the nativescript-sound
module. Note that the media object is initialized when the start-up page loads and played on button click.
Please have a look at it and let me know if it helps.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items