@Lay wrote:
I've got an ionic app that uses cordovaNativeAudio plugin for playing audio files. The app is kinda a foreign language dictionary where the user can listen to the vocabulary to learn how they are pronounced. The audio files have a duration of only few seconds. And I've got around 80 mp3 files - for each vocabulary one audio file.
I've noticed that in the beginning it would play the audio files just fine, but after a while the audio files of vocabularies that I haven't played yet won't play. Meaning I can play approx. 15 audio files. After that no other audio files can be playback that I haven't played already.
This is the code I'm using: Each slide of my app is able to play several audio files. For each slide I wrote a code similar to this:
For slide 1:function SoundController_slide_1($ionicPlatform, $timeout, $cordovaNativeAudio) { var vm = this; $ionicPlatform.ready(function() { $cordovaNativeAudio.preloadSimple('slide_1_a', 'audio/slide_1_a.mp3'); $cordovaNativeAudio.preloadSimple('slide_1_b', 'audio/slide_1_b.mp3'); }); vm.play = function(sound) { $cordovaNativeAudio.play(sound); }; return vm; }
For slide 2:
function SoundController_slide_2($ionicPlatform, $timeout, $cordovaNativeAudio) { var vm = this; $ionicPlatform.ready(function() { $cordovaNativeAudio.preloadSimple('slide_2_a', 'audio/slide_2_a.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_b', 'audio/slide_2_b.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_c', 'audio/slide_2_c.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_d', 'audio/slide_2_d.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_e', 'audio/slide_2_e.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_f', 'audio/slide_2_f.mp3'); $cordovaNativeAudio.preloadSimple('slide_2_g', 'audio/slide_2_g.mp3'); }); vm.play = function(sound) { $cordovaNativeAudio.play(sound); }; return vm; }
...and so on for the other slides. In total I've got several soundcontrollers like that. Each for every vocabulary slide. I then call them like this:
.controller('SoundController_slide_1', ['$ionicPlatform', '$timeout', '$cordovaNativeAudio', SoundController_slide_1]) .controller('SoundController_slide_2', ['$ionicPlatform', '$timeout', '$cordovaNativeAudio', SoundController_slide_2])
In the view I would call the audio files like this:
<button ng-if="foo()" ng-click="vm.play('slide_1_a')" class="button icon-left ion-play">Vocabulary 1</button> <button ng-if="foo2()" ng-click="vm.play('slide_1_b')" class="button icon-left ion-play">Vocabulary 2</button>
And it works. The audio files are playback. But after a while it seems like I can't load more audio files. Is the reason why after a while no new audio files can be playback is because there are so many audio files loaded already? How can I fix that? What if I wanted to implement an app that playback up to 1.000 (small) audio files?
Posts: 1
Participants: 1