move audio playback to background page to avoid the page's own CSP interfering
This commit is contained in:
1 parent
f982de54d3
commit
8317f44270
3 files changed
+10
-17
No files matched your search
@@ -1 +1,2 @@
|
|||||||
dict/JMDict*.json
|
dict/JMDict*.json
|
||||||
|
nazeka@wareya.moe.xpi
|
||||||
@@ -1452,6 +1452,14 @@ browser.runtime.onMessage.addListener((req, sender) =>
|
|||||||
});
|
});
|
||||||
xhr.send(req.command);
|
xhr.send(req.command);
|
||||||
}
|
}
|
||||||
|
else if (req.type == "play_audio")
|
||||||
|
{
|
||||||
|
let audio = new Audio(req.host);
|
||||||
|
audio.volume = req.volume;
|
||||||
|
audio.play();
|
||||||
|
console.log("tried to play audio");
|
||||||
|
console.log(req.host);
|
||||||
|
}
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+1
-17
@@ -1657,23 +1657,7 @@ async function try_to_play_audio()
|
|||||||
if(fields)
|
if(fields)
|
||||||
{
|
{
|
||||||
let url = "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=" + fields[0] + "&kanji=" + fields[1];
|
let url = "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=" + fields[0] + "&kanji=" + fields[1];
|
||||||
let audio = new Audio(url);
|
browser.runtime.sendMessage({type:"play_audio", host:url, volume:settings.volume});
|
||||||
audio.volume = settings.volume;
|
|
||||||
audio.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function try_to_play_audio()
|
|
||||||
{
|
|
||||||
if(!exists_div())
|
|
||||||
return;
|
|
||||||
let fields = get_audio_text(get_div());
|
|
||||||
if(fields)
|
|
||||||
{
|
|
||||||
let url = "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=" + fields[0] + "&kanji=" + fields[1];
|
|
||||||
let audio = new Audio(url);
|
|
||||||
audio.volume = settings.volume;
|
|
||||||
audio.play();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user