I have two functions in JavaScript
. Its working fine on Windows 7
Chrome
but loadedAudio_chrome
function is not being fired on IPAD
.
function preloadAudio_chrome(url)
{
try
{
var audio = new Audio();
audio.addEventListener('canplaythrough', loadedAudio_chrome, false);
//audio.src = filePath;
} catch (e) {
alert(e.message);
}
}
function loadedAudio_chrome()
{
//alert('not firing this alert on IPAD');
}
You seem to be missing audio.load() from your snippet, try adding that as shown below and it should work.
function preloadAudio_chrome(url)
{
try
{
var audio = new Audio();
audio.addEventListener('canplaythrough', loadedAudio_chrome, false);
// EDIT HERE ADD audio.load();
audio.load();
} catch (e) {
alert(e.message);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.