Skip to content

Commit

Permalink
feat(time): A tic/toc sound now plays on the atomic clock for easy se…
Browse files Browse the repository at this point in the history
…tting up

Fixes #90
  • Loading branch information
MathieuNls committed Mar 14, 2017
1 parent bc533eb commit 51cc412
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Binary file added src/assets/sounds/tic.mp3
Binary file not shown.
Binary file added src/assets/sounds/toc.mp3
Binary file not shown.
20 changes: 19 additions & 1 deletion src/pages/time/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -58,6 +61,7 @@ export class TimePage extends ClockComponent{

ionViewCanLeave():boolean {
clearInterval(this.interval);
clearInterval(this.soundInterval);
return true;
}

Expand All @@ -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()
Expand Down

0 comments on commit 51cc412

Please sign in to comment.