Javascript AppMobi,html5声音在模拟器和android上工作,但在iphone上不工作

Javascript AppMobi,html5声音在模拟器和android上工作,但在iphone上不工作,javascript,html,appmobi,Javascript,Html,Appmobi,今天我开始在appmobi学习。我正在开发一个处理声音的小示例 我只需要创建一个处理程序来播放和停止许多声音 var audioOn = new Audio('sounds/11.mp3'); audioOn.play(); 这段代码在xdk模拟器中运行,同样在android设备上运行,但在我的Iphone 5中不运行 问题是,如果我使用tag,它可以在iphone上运行,但我想使用javascript原生api来处理声音等 我一直试图用appmobi播放器库来处理它,但它没有停止、恢复等控

今天我开始在appmobi学习。我正在开发一个处理声音的小示例

我只需要创建一个处理程序来播放和停止许多声音

var audioOn = new Audio('sounds/11.mp3'); 
audioOn.play();
这段代码在xdk模拟器中运行,同样在android设备上运行,但在我的Iphone 5中不运行

问题是,如果我使用tag,它可以在iphone上运行,但我想使用javascript原生api来处理声音等

我一直试图用appmobi播放器库来处理它,但它没有停止、恢复等控件,这就是我想使用native的方式

下面是javascript代码的一部分:

<script type="text/javascript">
/* This function runs once the page is loaded, but appMobi is not yet active */
var init = function(){
var alarmButton = document.getElementById("alarmButton");
var on = false;
//var audioOn = new Audio('http://rpg.hamsterrepublic.com/wiki-images/3/3e/Heal8-Bit.ogg');

var audioOn = new Audio('sounds/11.mp3'); 
audioOn.addEventListener('ended', function() {
this.play();
}, false);

var but = function(){
alert("but");
alert(on);
alert(audioOn);

if(!on){
on = true;
audioOn.currentTime = 0;
audioOn.play(); 
}
else{
on = false;
audioOn.pause(); 
}
}
//alarmButton.addEventListener("click",but,false);
alarmButton.addEventListener("touchstart",but,false);
alarmButton.addEventListener("tap",but,false);

};

window.addEventListener("load",init,false);

/* This code prevents users from dragging the page */
var preventDefaultScroll = function(event) {
event.preventDefault();
window.scroll(0,0);
return false;
};
document.addEventListener('touchmove', preventDefaultScroll, false);

/* This code is used to run as soon as appMobi activates */
var onDeviceReady=function(){
//Size the display to 768px by 1024px
AppMobi.display.useViewport(768,1024);
//hide splash screen
AppMobi.device.hideSplashScreen(); 
};

document.addEventListener("appMobi.device.ready",onDeviceReady,false);

function echo(){
alert("clicked");
}

</script>

/*此函数在加载页面后运行,但appMobi尚未激活*/
var init=函数(){
var alarmButton=document.getElementById(“alarmButton”);
var on=假;
//var audioOn=新的音频文件('http://rpg.hamsterrepublic.com/wiki-images/3/3e/Heal8-Bit.ogg');
var audioOn=新音频('sounds/11.mp3');
audioOn.addEventListener('end',function(){
这个。play();
},假);
var但是=函数(){
警惕(“但是”);
警报(开启);
警报(音频);
如果(!on){
开=真;
audioOn.currentTime=0;
audioOn.play();
}
否则{
开=假;
audioOn.pause();
}
}
//alarmButton.addEventListener(“单击”,但为false);
alarmButton.addEventListener(“touchstart”,但为false);
alarmButton.addEventListener(“点击”,但为假);
};
addEventListener(“加载”,init,false);
/*此代码防止用户拖动页面*/
var preventDefaultScroll=函数(事件){
event.preventDefault();
窗口。滚动(0,0);
返回false;
};
document.addEventListener('touchmove',preventDefaultScroll,false);
/*此代码用于在appMobi激活后立即运行*/
var ondevicerady=函数(){
//将显示器的大小调整为768px×1024px
AppMobi.display.useViewport(7681024);
//隐藏启动屏幕
AppMobi.device.hideSplashScreen();
};
document.addEventListener(“appMobi.device.ready”,ondevicerady,false);
函数echo(){
警报(“点击”);
}

非常感谢

这似乎不是appmobi的问题

我认为iphone的appmobi实验室应用程序使用safari mobile来运行html5测试

因此,这是一个狩猎移动事件

由onclick事件启动时,play()似乎可以工作。看

需要执行一些测试…

我必须尝试以下方法:

在现代浏览器中支持HTML5音频可能会很乏味,更不用说了 传统的。真实世界的访问者使用的浏览器范围从 从mobile Safari到IE 6,可以跨越多种设备 许多支持案例需要考虑。

SoundManager 2为您提供了一个强大的API,支持两种新的 旧版,在支持的地方使用HTML5音频,可选基于Flash 在需要的地方撤退。理想情况下,使用SoundManager 2时,音频“仅 工作。”


是的,Intel JavaScript API()仅在使用云构建系统构建的移动混合应用程序的上下文中可用。如果要在Mobile Safari中运行该Web代码,它将无法访问appMobi库对象。请参阅