🔊 Set up audio service

This commit is contained in:
corner 2019-09-09 18:22:53 +02:00
parent 7f4eb556d5
commit 4475249c34
3 changed files with 27 additions and 2 deletions

3
.gitignore vendored
View File

@ -44,3 +44,6 @@ testem.log
# System Files # System Files
.DS_Store .DS_Store
Thumbs.db Thumbs.db
# Environment variables should be hidden for testing only
/src/environments

View File

@ -5,5 +5,26 @@ import { Injectable } from '@angular/core';
}) })
export class AudioService { export class AudioService {
constructor() { } player = new Audio();
constructor() {
}
play() {
this.player.play();
}
pause() {
this.player.pause();
}
toggle() {
if (this.player.paused) this.player.play();
else this.player.pause();
}
setSong(path: string) {
this.player.src = path;
}
} }

View File

@ -6,6 +6,7 @@
"deprecation": { "deprecation": {
"severity": "warning" "severity": "warning"
}, },
"curly": false,
"component-class-suffix": true, "component-class-suffix": true,
"contextual-lifecycle": true, "contextual-lifecycle": true,
"directive-class-suffix": true, "directive-class-suffix": true,
@ -89,4 +90,4 @@
"rulesDirectory": [ "rulesDirectory": [
"codelyzer" "codelyzer"
] ]
} }