If you want to decode Audio Data, createMediaElementSource() is not working on mobile devices, However createBufferSource() method is working properly:
This code is working properly in web browsers, but not in mobile devices:
var audioSource = new Audio();
audioSource.src= "Test.mp3";
var audioCtx = new AudioContext();
var sourceT1 = audioCtx.createMediaElementSource(audioSource); //This is the source audio
//My Decoding...
And this code is working for both Web and Mobile browsers:
var audioSource = new Audio();
var audioCtx = new AudioContext();
var sourceT2 = audioCtx.createBufferSource(); //This is the source audio
request = new XMLHttpRequest();
request.open('GET', 'Test.mp3', true);
request.responseType = 'arraybuffer';
request.onload = function() {
var audioData = request.response;
audioCtx.decodeAudioData(audioData, function(myBuffer) {
sourceT2.buffer = myBuffer;
//My Decoding...
},
function(e){"Error with decoding audio data" + e.err});
}
In my case I have an Audio source that comes from a video player to be decoded, which is a MediaElementAudioSourceNode, and I need to convert it to a AudioBufferSourceNode in order to get my code working on mobile devices, In other words, is it possible to convert sourceT1 to sourceT2?
Any Idea how to do it?
EDIT: Based on this answer, unfortunatly I think it is impossible to do it