diff --git a/src/assets/sounds/tic.mp3 b/src/assets/sounds/tic.mp3 new file mode 100644 index 0000000..df3035d Binary files /dev/null and b/src/assets/sounds/tic.mp3 differ diff --git a/src/assets/sounds/toc.mp3 b/src/assets/sounds/toc.mp3 new file mode 100644 index 0000000..f6bbbe3 Binary files /dev/null and b/src/assets/sounds/toc.mp3 differ diff --git a/src/pages/time/time.ts b/src/pages/time/time.ts index 0375577..315ec53 100755 --- a/src/pages/time/time.ts +++ b/src/pages/time/time.ts @@ -26,6 +26,9 @@ export class TimePage extends ClockComponent{ loading:Loading; twelveHoursFormat:boolean = true; interval:any; + soundInterval:any; + tic = new Audio('assets/sounds/tic.mp3'); + toc = new Audio('assets/sounds/toc.mp3'); constructor( @@ -58,6 +61,7 @@ export class TimePage extends ClockComponent{ ionViewCanLeave():boolean { clearInterval(this.interval); + clearInterval(this.soundInterval); return true; } @@ -68,13 +72,27 @@ export class TimePage extends ClockComponent{ this.twapi.accurateTime().then( date => { + let ms = this.date.getMilliseconds() + + setTimeout(()=>{ + this.soundInterval = setInterval(()=>{ + ms = 0; + if(this.date.getSeconds() % 2 == 0){ + this.tic.play(); + }else{ + this.toc.play(); + } + }, 1000); + }, 990-ms) + + this.interval = setInterval(()=>{ this.date = new Date(this.date.getTime() + this.intervalTime); this.initLocalClocks(); - console.log(this.date.getMilliseconds()); }, this.intervalTime ); + setTimeout(()=>{ this.loading.dismiss()