From 62eaea018236c2ee4e492b0f0d16c194d1ac9362 Mon Sep 17 00:00:00 2001 From: itzMiney Date: Sat, 21 Mar 2026 23:41:03 +0100 Subject: [PATCH] some cleanup n stuff ig --- angular.json | 5 +- src/app/admin/admin.component.css | 4 ++ src/app/admin/admin.component.html | 2 +- .../audio-player/audio-player.component.css | 9 +++- .../audio-player/audio-player.component.html | 36 +++++++------- .../audio-player/audio-player.component.ts | 47 +++++++++++++++---- src/index.html | 6 --- src/styles.css | 3 +- 8 files changed, 74 insertions(+), 38 deletions(-) diff --git a/angular.json b/angular.json index 8bca3fc..8a5d987 100644 --- a/angular.json +++ b/angular.json @@ -28,7 +28,10 @@ } ], "styles": [ - "src/styles.css" + "src/styles.css", + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/fontawesome.min.css", + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/brands.min.css", + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/solid.min.css" ], "scripts": [ ] diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css index 6116a73..76c9dee 100644 --- a/src/app/admin/admin.component.css +++ b/src/app/admin/admin.component.css @@ -18,6 +18,10 @@ .title h2 { margin: 10px; + background: linear-gradient(to top, #a0eddb 0%, #ffffff 100%); + -webkit-background-clip: text; + background-clip: text; + color: transparent; } .logo { diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html index 47b3040..8cce45c 100644 --- a/src/app/admin/admin.component.html +++ b/src/app/admin/admin.component.html @@ -18,7 +18,7 @@
-
+
-
-

{{ nowPlayingTitle() }}

-
- - - - @if (isPlayerReady()) { -
- +
+

{{ nowPlayingTitle() }}

+
+ + + + @if (isPlayerReady()) { +
+
} diff --git a/src/app/shared/audio-player/audio-player.component.ts b/src/app/shared/audio-player/audio-player.component.ts index 6cdecb5..f0c21d1 100644 --- a/src/app/shared/audio-player/audio-player.component.ts +++ b/src/app/shared/audio-player/audio-player.component.ts @@ -25,6 +25,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit { isPlayerReady = signal(false); isPlaying = signal(false); nowPlayingTitle = signal(''); + volume = signal(50) constructor(private deviceService: ViewportService) {} @@ -33,16 +34,40 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit { } ngAfterViewInit() { - if (window.YT && window.YT.Player) { + void this.loadYouTubeApi().then(() => { this.createPlayer(); - } else { - window.onYouTubeIframeAPIReady = () => this.createPlayer(); - } + }); + } + + private loadYouTubeApi(): Promise { + return new Promise((resolve) => { + if (window.YT?.Player) { + resolve(); + return; + } + + const existingScript = document.querySelector( + 'script[src="https://www.youtube.com/iframe_api"]' + ); + + if (existingScript) { + window.onYouTubeIframeAPIReady = () => resolve(); + return; + } + + const script = document.createElement('script'); + script.src = 'https://www.youtube.com/iframe_api'; + script.async = true; + + window.onYouTubeIframeAPIReady = () => resolve(); + + document.head.appendChild(script); + }); } createPlayer() { this.player = new window.YT.Player('youtube-player', { - height: '0', // or something minimal + height: '0', width: '0', playerVars: { listType: 'playlist', @@ -54,7 +79,6 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit { onReady: () => { this.isPlayerReady.set(true); this.player.setVolume(this.volume()); - console.log('YouTube Player Ready'); const iframe = document.getElementById('youtube-player') as HTMLIFrameElement | null; if (iframe) { @@ -70,7 +94,13 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit { }, onStateChange: (event: any) => { if (event.data === window.YT.PlayerState.PLAYING) { + this.isPlaying.set(true); this.updateNowPlayingTitle(); + } else if ( + event.data === window.YT.PlayerState.PAUSED || + event.data === window.YT.PlayerState.ENDED + ) { + this.isPlaying.set(false); } } } @@ -120,15 +150,14 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit { } } - volume = signal(50); - onVolumeChange(event: Event) { const target = event.target as HTMLInputElement; const newVolume = parseInt(target.value, 10); + this.volume.set(newVolume); + if (this.isPlayerReady() && this.player?.setVolume) { this.player.setVolume(newVolume); - this.volume.set(newVolume); } } } diff --git a/src/index.html b/src/index.html index 5915ae5..4d673c1 100644 --- a/src/index.html +++ b/src/index.html @@ -1,7 +1,6 @@ - itzMiney's Home @@ -11,11 +10,6 @@ - - - - - diff --git a/src/styles.css b/src/styles.css index ee939ea..4c68c48 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1,4 +1,5 @@ -/* You can add global styles to this file, and also import other style files */ +@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap'); +@import url('https://fonts.googleapis.com/icon?family=Material+Icons'); html, body { height: 100%;