I have an audio app that loops sounds for playback using Cordova 2.2 and its Audio API. At the moment I have setup a number of loops that will stop when finished based on predetermined time (calculated on n seconds per loop / 3 hours) . This method generally works.
playMainAudio = new Media(url,
// success callback
function() {
console.log("playAudio():Audio Success");
},
// error callback
function(err) {
console.log("playAudio():Audio Error: "+err);
});
// Play audio
playMainAudio.play({ numberOfLoops: 123, playAudioWhenScreenIsLocked : true });
But I'd prefer a native code addition where I could just set all audio to stop after 3 hours rather then work it out based on time- but not sure were to look or even place the code. The catch is it has to work when locked or the app is in the background (currently I have the correct background mode set so the audio will play in the BG).
is there a native timer that is background compatible ?