科尔多瓦iOS Webview预加载声音?

时间:2018-08-30 15:39:07

标签: javascript ios cordova

这里的非常简单的代码无法在通过Cordova的iOS UIWebview上正常工作,而在Android上完美地工作,正在寻找解决方法。声音永远不会加载到iOS上(oncanplaythrough永远不会触发)。

 var snd = new Audio();
 snd.preload = 'auto'; 
 snd.oncanplaythrough = function(){
      console.log('the sound is loaded!');
 });
 snd.src = 'whatever.mp3';

1 个答案:

答案 0 :(得分:1)

要回答我自己的问题,可能会对某人有所帮助。事实证明,iOS Webview忽略

 snd.preload='auto';

但可以通过删除它来代替

 snd.load();