If we use the code below:
var media = new Media('url://...mp3', null, null, mediaStatusCallback);
media.play();
Well this will first download the hole mp3 file, then play it. But the problem is if we have a large size audio file it will be stuck till it finishes downloading the hole file, this delays the player or unusable, but instead I want to download part of the mp3 file as array buffer asynchronously and play it using cordova media plugin until the next part of the audio file is downloaded. This will continue until the hole file is downloaded while part of the audio is playing.
Basically it like like web audio API uses to buffer an audio but play it with cordova media plugin.
var url = "sample_audio.mp3";
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = "arraybuffer";
/* Asynchronous callback */
request.onload = function()
{
/* Create the sound source */
soundSource = context.createBufferSource();
/* Import callback function that provides PCM audio data decoded as an audio buffer */
context.decodeAudioData(request.response, function(buffer)
{
bufferData = buffer;
soundSource.buffer = bufferData;
}, this.onDecodeError);
};
request.send();
Is there anyone who can help me achieve that? I've been stuck on this one for a while.
Thanks in advance.