gpt4 book ai didi

javascript - Android 浏览器 html5 音频无法播放

转载 作者:行者123 更新时间:2023-12-03 02:05:00 25 4
gpt4 key购买 nike

我正在制作一个播放小 mp3 文件以通知用户更新的网络应用程序。我正在使用 HTML5 音频 API:

var notifyAudio = new Audio("path/to/audio.mp3");
//some code...
//Callback function called when I want to notify the user
function notify(){
notifyAudio.play()
}

它在 Chrome 桌面浏览器中完美运行,但是当我在 Android 设备上测试它时,它不会,甚至没有加载 mp3 文件,她是我在 Chrome 设备调试器中得到的

enter image description here

最佳答案

我相信您需要在 Android 中为使用/android_asset/www 播放媒体的路径添加前缀。在此处查看我的博客文章以获得完整的演示 - http://www.raymondcamden.com/2014/06/23/Cordova-Media-API-Example .另外,请确保您确实添加了媒体插件。

关于javascript - Android 浏览器 html5 音频无法播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28168951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com