some cleanup n stuff ig
This commit is contained in:
1 parent
aaa1468a15
commit
62eaea0182
8 files changed
+74
-38
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="main-separator"></div>
|
||||
|
||||
<div class="article-input-box">
|
||||
<form #articleForm="ngForm" (ngSubmit)="submitArticle()">
|
||||
<form (ngSubmit)="submitArticle()">
|
||||
<div class="action-bar" [class.mobile]="isNarrow">
|
||||
<input
|
||||
id="editTitle"
|
||||
|
||||
@@ -54,6 +54,12 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10;
|
||||
opacity: 0;
|
||||
transition: all ease-in-out 0.2s;
|
||||
}
|
||||
|
||||
.audio-player.visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.audio-player.mobile {
|
||||
@@ -62,9 +68,8 @@
|
||||
}
|
||||
|
||||
.audio-player h3 {
|
||||
margin-left: 15px;
|
||||
text-align: center;
|
||||
font-family: Roboto, sans-serif;
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
color: white;
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
<div class="audio-player" [ngClass]="{ mobile: isNarrow }">
|
||||
<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>
|
||||
@if (isPlayerReady()) {
|
||||
<div class="volume-control">
|
||||
<input
|
||||
id="volume"
|
||||
type="range"
|
||||
min="0"
|
||||
max="100"
|
||||
[value]="volume()"
|
||||
(input)="onVolumeChange($event)"
|
||||
<div class="audio-player" [ngClass]="{ mobile: isNarrow }" [class.visible]="isPlayerReady()">
|
||||
<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>
|
||||
@if (isPlayerReady()) {
|
||||
<div class="volume-control">
|
||||
<input
|
||||
id="volume"
|
||||
type="range"
|
||||
min="0"
|
||||
max="100"
|
||||
[value]="volume()"
|
||||
(input)="onVolumeChange($event)"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
||||
isPlayerReady = signal(false);
|
||||
isPlaying = signal(false);
|
||||
nowPlayingTitle = signal<string>('');
|
||||
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<void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="https://www.youtube.com/iframe_api"></script>
|
||||
<title>itzMiney's Home</title>
|
||||
<meta charset="utf-8">
|
||||
<base href="/">
|
||||
@@ -11,11 +10,6 @@
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/fontawesome.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/brands.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/solid.min.css">
|
||||
</head>
|
||||
<body class="mat-typography">
|
||||
<app-root></app-root>
|
||||
|
||||
+2
-1
@@ -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%;
|
||||
|
||||
Reference in new issue
Block a user