From 4475249c34abfdebe27bcb92652ec99b82957aa0 Mon Sep 17 00:00:00 2001 From: stickyPiston Date: Mon, 9 Sep 2019 18:22:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Set=20up=20audio=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ src/app/services/audio.service.ts | 23 ++++++++++++++++++++++- tslint.json | 3 ++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f4f46a5..2e1f7d3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ testem.log # System Files .DS_Store Thumbs.db + +# Environment variables should be hidden for testing only +/src/environments diff --git a/src/app/services/audio.service.ts b/src/app/services/audio.service.ts index f7f1c41..0cae671 100644 --- a/src/app/services/audio.service.ts +++ b/src/app/services/audio.service.ts @@ -5,5 +5,26 @@ import { Injectable } from '@angular/core'; }) 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; + } } diff --git a/tslint.json b/tslint.json index f0adae9..0147588 100644 --- a/tslint.json +++ b/tslint.json @@ -6,6 +6,7 @@ "deprecation": { "severity": "warning" }, + "curly": false, "component-class-suffix": true, "contextual-lifecycle": true, "directive-class-suffix": true, @@ -89,4 +90,4 @@ "rulesDirectory": [ "codelyzer" ] -} \ No newline at end of file +}