Updated audio player on portfolio page

This commit is contained in:
itzMiney committed 2025-05-07 14:21:44 +02:00
1 parent a6edfc9f7e
commit 92d7fba166
3 files changed
+56 -2

No files matched your search

@@ -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;
@@ -1,11 +1,21 @@
<div class="audio-player">
<div id="youtube-player"></div>
<h3>{{ nowPlayingTitle() }}</h3>
<div class="controls">
<button (click)="previousVideo()" [disabled]="!isPlayerReady"><i class="fa-solid fa-backward"></i></button>
<button (click)="togglePlayPause()" [disabled]="!isPlayerReady">
<i class="{{ isPlaying() ? 'fa-solid fa-pause' : 'fa-solid fa-play'}}"></i>
</button>
<button (click)="nextVideo()" [disabled]="!isPlayerReady"><i class="fa-solid fa-forward"></i></button>
<h3>{{ nowPlayingTitle() }}</h3>
<div class="volume-control" *ngIf="isPlayerReady()">
<input
id="volume"
type="range"
min="0"
max="100"
[value]="volume()"
(input)="onVolumeChange($event)"
/>
</div>
</div>
</div>
@@ -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);
}
}
}