第一个功能完成后,有没有办法使用其他功能?
调用号码时将使用第一个函数。 它将循环播放并播放音频。
function sound() {
number2 = get.num; // '1002', '2003' etc.
sNumber = number2.toString();
output = [];
delay = 2000;
callon = new Audio('logo/call.wav');
callon.play();
for ( i = 0, len = sNumber.length; i < len; i ++) {
output.push(+sNumber.charAt(i));
console.log(output);
switch (output[i])
{
case 0:
audio0 = new Audio('logo/Q0.wav');
// audio0.play();
setTimeout(function(){audio0.play();},delay);
console.log(output[i]);
break;
case 1:
console.log('1');
audio1 = new Audio('logo/Q1.wav');
// audio0.play();
setTimeout(function(){audio1.play();},delay);
break;
case 2:
audio2 = new Audio('logo/Q2.wav');
// audio0.play();
console.log(output[i]);
setTimeout(function(){audio2.play();},delay);
break;
case 3:
console.log('3');
audio3 = new Audio('logo/Q3.wav');
// audio0.play();
setTimeout(function(){audio3.play();},delay);
break;
}
delay = delay + 1100;
}service();
}
第二个功能是指在第一个功能完成后播放另一个声音。
function service() {
var sService = get.service;
if( sService == '2'){
console.log('got in!');
call2 = new Audio('logo/ch02.wav');
call2.play();
}}