I have a content script which reads data and using google tts service gets the output audio.
The problem concerns injecting script through extension
When i inject the audio element through javascript I see the right url being called and audio element appended . But it doesnt play . I have set autoplay attribute .
Snippet I am using
var url = 'http://translate.google.com/translate_tts?tl=en&q=' + encoded;
console.log(url);
var audio = new Audio();
audio.setAttribute('src',url);
audio.setAttribute('autoplay');
var t = document.getElementById('doc');
if(t.appendChild(audio)){
console.log('appended');
}
https://chrome.google.com/webstore/developer/detail/dhfpnmpbgjadmhggjeajdfmkcclckeim
The problem is that you cannot load audio through content script . This can however be achieved using background page .