Software Archive
Read-only legacy content
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
17066 Discussions

How to use setinterval on Intel XDK?

Adam_Suchi_Hafizulla
83 Views

Hi, i want to use setinterval function on intel XDK, but when i test it on android App Preview, the setinterval function is working, and when i use it on the real devices, it not working.

I just want to make a check status every second for connecting audio online like this:
 

function checkStatus(){
if(radio.currentTime > 0 && !radio.paused){
 status.innerHTML = "<font color='#00ce27'>Connected</font>";
}
}
setInterval(checkStatus,1000);

 

Thank you before ^^

0 Kudos
3 Replies
PaulF_IntelCorp
Employee
83 Views

Adam -- try a simpler test, like:

var toggle = true ;
function checkStatus() {
    if(toggle) {
        status.innerHTML = "<font color="#FF0000" face="courier" size="10">RED</font>";
        toggle = false ;
    }
    else {
        status.innerHTML = "<font color="#000000" face="courier" size="10">BLACK</font>";
        toggle = true ;
    }
}
setInterval(checkStatus,1000) ;

Could also be due to this > http://www.w3schools.com/tags/tag_font.asp

Adam_Suchi_Hafizulla
83 Views

Paul F. (Intel) wrote:

Adam -- try a simpler test, like:

var toggle = true ;
function checkStatus() {
    if(toggle) {
        status.innerHTML = "<font color="#FF0000" face="courier" size="10">RED</font>";
        toggle = false ;
    }
    else {
        status.innerHTML = "<font color="#000000" face="courier" size="10">BLACK</font>";
        toggle = true ;
    }
}
setInterval(checkStatus,1000) ;

Could also be due to this > http://www.w3schools.com/tags/tag_font.asp

 

Thanks for your reply ^^. But i just want to check every second is the audio playing or not yet, i think <audio> currentTime is not working on Intel XDK?

PaulF_IntelCorp
Employee
83 Views

Adam -- I recommend you first debug your problem with setInterval. It sounds like you've got multiple issues at play, and it's better to fix one issue at a time, thus my recommendation. I have no idea what the radio object is, so I cannot comment on that.

Reply