I am working on a phonegap / cordova application that plays audio files stored locally.
I am having problems with some code and android where example 1 is not playing on android and example 2 is playing.
NOTE. Problems are not the way, I know that the path to the file is correct.
Example 1 - Does not work on Android, but works fine on iOS, where the path is changed for iOS.
var audiofile = cordova.file.dataDirectory+'android_asset/www/audio/1.aac'; ... $( ".player" ).html('<div class="audioDemo-wrapper"><audio class="audioDemo" controls><source src="'+audiofile+'" type="audio/mpeg"></audio><div class="closeAudioBtn" onclick="stopAndCloseAudio();">X</div></div>'); $(".audioDemo").trigger('play');
Example 2. This works on Android, but it is not as we would like.
var audiofile = cordova.file.dataDirectory+'android_asset/www/audio/1.aac'; window.open(audiofile, '_blank', 'location=no,closebuttoncaption=Close');
The main difference is that a new example opens in a new window? 2.
Why example 1 does not play on Android when it works fine on iOS (Note: paths are not a problem)
Any ideas?
source share