Quantcast
Channel: Foren
Viewing all articles
Browse latest Browse all 170

AppMobi HTML5 audio element problems on Iphone

$
0
0

Hello everyone,

Today I get started in appmobi. I was developing a small example to deal with sounds.

I just needed to create a handler to play and stop many sounds. 

var audioOn = new Audio('sounds/11.mp3'); 
audioOn.play();

This code is working in the xdk simulator, also on android devices, but not in my Iphone 5.

The thing is, if I use <audio> tag it works on iphone, but I want to use javascript native api to deal with sounds and more.

I have been trying to deal with it with appmobi player library but it comes without controls to stop, resume etc, thats way I want to use native.

Here is part of javascript code :

<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>

Thanks a lot 

 


Viewing all articles
Browse latest Browse all 170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>