From 92d7fba1668952d296ecb48878c691b34e5663cf Mon Sep 17 00:00:00 2001 From: itzMiney Date: Wed, 7 May 2025 14:21:44 +0200 Subject: [PATCH] Updated audio player on portfolio page --- .../audio-player/audio-player.component.css | 28 +++++++++++++++++++ .../audio-player/audio-player.component.html | 12 +++++++- .../audio-player/audio-player.component.ts | 18 +++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/app/shared/audio-player/audio-player.component.css b/src/app/shared/audio-player/audio-player.component.css index f915a48..9e5c3ad 100644 --- a/src/app/shared/audio-player/audio-player.component.css +++ b/src/app/shared/audio-player/audio-player.component.css @@ -15,6 +15,34 @@ border-radius: 25px; } +.volume-control input[type="range"] { + -webkit-appearance: none; + width: 150px; + background: #43497e; + border-radius: 15px; + height: 6px; + margin-bottom: 3px; +} + +.volume-control input[type="range"]::-moz-range-thumb { + -webkit-appearance: none; + height: 16px; + width: 16px; + border-radius: 10px; + background: #ffffff; + border: none; + cursor: pointer; + margin-top: -6px; /* align with track */ +} + +.volume-control input[type="range"]::-moz-range-progress { + width: 150px; + background: #818aec; + border-radius: 15px; + height: 6px; + margin-bottom: 3px;; +} + .audio-player { position: fixed; bottom: 10px; diff --git a/src/app/shared/audio-player/audio-player.component.html b/src/app/shared/audio-player/audio-player.component.html index ee32331..c6f8da6 100644 --- a/src/app/shared/audio-player/audio-player.component.html +++ b/src/app/shared/audio-player/audio-player.component.html @@ -1,11 +1,21 @@
+

{{ nowPlayingTitle() }}

-

{{ nowPlayingTitle() }}

+
+ +
diff --git a/src/app/shared/audio-player/audio-player.component.ts b/src/app/shared/audio-player/audio-player.component.ts index bf05bc4..a9353a5 100644 --- a/src/app/shared/audio-player/audio-player.component.ts +++ b/src/app/shared/audio-player/audio-player.component.ts @@ -1,4 +1,5 @@ import {Component, AfterViewInit, signal} from '@angular/core'; +import {NgIf} from '@angular/common'; declare global { interface Window { @@ -9,7 +10,9 @@ declare global { @Component({ selector: 'app-audio-player', - imports: [], + imports: [ + NgIf + ], templateUrl: './audio-player.component.html', styleUrl: './audio-player.component.css' }) @@ -40,6 +43,7 @@ export class AudioPlayerComponent implements AfterViewInit { events: { onReady: () => { this.isPlayerReady.set(true); + this.player.setVolume(this.volume()); console.log('YouTube Player Ready'); const iframe = document.getElementById('youtube-player') as HTMLIFrameElement | null; @@ -105,4 +109,16 @@ export class AudioPlayerComponent implements AfterViewInit { this.player.previousVideo(); } } + + volume = signal(50); + + onVolumeChange(event: Event) { + const target = event.target as HTMLInputElement; + const newVolume = parseInt(target.value, 10); + + if (this.isPlayerReady() && this.player?.setVolume) { + this.player.setVolume(newVolume); + this.volume.set(newVolume); + } + } }