Sound files stop to play after a number of them are played


#1

I have a flashcard app where there are sound files for words. Sound files change 3-5kb. and in total does not exceed 1mb. In my code first I create the sound files then are played when tapped or when the page is loaded. the app works fine in iOS simulator but I run the app in android device in the fourteenth word the sounds stop playing. Is there any issues with number of audio files to be played in an android version of the app.


#2

Do you get any errors in log?
Does it stop in particular sound every time? If Yes, did you try playing others?
Can you share some code how you are doing it?


#3

Thanks for reply,
I do not get any errors in log.
It does not stop at particular sound. I tried with different ones.
It seems as if there is a limit of sound files. Every time it stops playing at the fourteenth sound created.
the app runs smoothly in iOS simulator. I have not got any problem yet. in iOS simulator it plays all the sound files. But when I tested it with android device I got this error.

I put the relevant part of my code below. Thank you
var frames = require(“ui/frame”);
var observable = require(“data/observable”);
var viewModule = require(“ui/core/view”);
var sound = require(“nativescript-sound”);
var getViewById = require(“tns-core-modules/ui/core/view”).getViewById;

function Word(word, image, audio){
this.word=word;
this.image=image;
this.audio=sound.create(audio);
}
var index=0;
var prev;
var next;

var words=[
new Word(“Black”,“res://black”,"~/sounds/black.mp3"),
new Word(“Blue”,“res://blue”,"~/sounds/blue.mp3"),
.
.
.
.
.
.

]

function change_Next(args){
var page=args.object;
var current_word=new observable.fromObject({
word:words[index].word,
image:words[index].image,
});
page.page.bindingContext=current_word;
playSound();
}

function change_Prev(args){
var page=args.object;
var current_word=new observable.fromObject({
word:words[index].word,
image:words[index].image,
});
page.page.bindingContext=current_word;
playSound();
}

function playSound(){
words[index].audio.play();
}

function onTap_Audio(args){
playSound();
}
exports.onTap_Audio=onTap_Audio;


#4

I tried
const TNSPlayer = require(“nativescript-audio”).TNSPlayer;
function playSound(){
const player = new TNSPlayer();
player
.initFromFile({
audioFile: words[index].audio,
loop: false
})
.then(() => {
player.play();
});
}

but I got the same issue. Interestingly stops playing at the fourteenth sound created.