越来越错误,而在玩音从网址中铬的扩展

0

的问题

我试过很多种方法发挥一个声音从URL但是它不工作。

当我视察该网页有错误的控制台:

铬扩展://invalid/:1获得铬扩展://invalid/net::ERR_FAILED

未捕获的(在承诺)DOMException:未能负荷,因为没有支持的来源被发现。

清单。json:

"options_page": "./html/content.html",
"permissions": [
    "activeTab",
    "storage",
    "contextMenus",
    "http://*/*",
    "https://*/*",
    "tabs"
],
"web_accessible_resources": [
    "*.mp3",
    "*.ogg"
]

我这样做在options_page是content.html. 我还指定的'web_accessible_resources的权限脚本,但是仍然没有成功。 所有的音频链接储存在铬储存。

脚本,附在content.html:

document.addEventListener('click', function (e) { 
e.preventDefault();
if (e.target.matches('.audioBtn')) {   
    chrome.storage.local.get({ meanifyWords: [] }, (result) => { 
        let getWordsObj = result.meanifyWords;
        let getAudio = getWordsObj[e.target.id].audio;  //getAudio="//ssl.gstatic.com/dictionary/static/sounds/20200429/experience--_gb_1.8.mp3"
        let sound = new Audio(getAudio);
        sound.play();
    })
}
});

请告诉我任何改变上述代码,这将解决这个问题。 在此先感谢。

1

最好的答案

0

添加架构,以URL:

let getAudio = "https:" + getWordsObj[e.target.id].audio;
2021-11-14 15:12:18

是的,它的工作非常感谢你。
vinayak

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................