🔊 Set up audio service
This commit is contained in:
parent
7f4eb556d5
commit
4475249c34
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user