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
+4
-1
@@ -28,7 +28,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"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": [
|
"scripts": [
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
.title h2 {
|
.title h2 {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
|
background: linear-gradient(to top, #a0eddb 0%, #ffffff 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
background-clip: text;
|
||||||
|
color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<div class="main-separator"></div>
|
<div class="main-separator"></div>
|
||||||
|
|
||||||
<div class="article-input-box">
|
<div class="article-input-box">
|
||||||
<form #articleForm="ngForm" (ngSubmit)="submitArticle()">
|
<form (ngSubmit)="submitArticle()">
|
||||||
<div class="action-bar" [class.mobile]="isNarrow">
|
<div class="action-bar" [class.mobile]="isNarrow">
|
||||||
<input
|
<input
|
||||||
id="editTitle"
|
id="editTitle"
|
||||||
|
|||||||
@@ -54,6 +54,12 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
opacity: 0;
|
||||||
|
transition: all ease-in-out 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-player.visible {
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-player.mobile {
|
.audio-player.mobile {
|
||||||
@@ -62,9 +68,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.audio-player h3 {
|
.audio-player h3 {
|
||||||
margin-left: 15px;
|
|
||||||
text-align: center;
|
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
|
text-align: center;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
<div class="audio-player" [ngClass]="{ mobile: isNarrow }">
|
<div class="audio-player" [ngClass]="{ mobile: isNarrow }" [class.visible]="isPlayerReady()">
|
||||||
<div id="youtube-player"></div>
|
<div id="youtube-player"></div>
|
||||||
<h3>{{ nowPlayingTitle() }}</h3>
|
<h3>{{ nowPlayingTitle() }}</h3>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button (click)="previousVideo()" [disabled]="!isPlayerReady()"><i class="fa-solid fa-backward"></i></button>
|
<button (click)="previousVideo()" [disabled]="!isPlayerReady()"><i class="fa-solid fa-backward"></i></button>
|
||||||
<button (click)="togglePlayPause()" [disabled]="!isPlayerReady()">
|
<button (click)="togglePlayPause()" [disabled]="!isPlayerReady()">
|
||||||
<i class="{{ isPlaying() ? 'fa-solid fa-pause' : 'fa-solid fa-play'}}"></i>
|
<i class="{{ isPlaying() ? 'fa-solid fa-pause' : 'fa-solid fa-play'}}"></i>
|
||||||
</button>
|
</button>
|
||||||
<button (click)="nextVideo()" [disabled]="!isPlayerReady()"><i class="fa-solid fa-forward"></i></button>
|
<button (click)="nextVideo()" [disabled]="!isPlayerReady()"><i class="fa-solid fa-forward"></i></button>
|
||||||
@if (isPlayerReady()) {
|
@if (isPlayerReady()) {
|
||||||
<div class="volume-control">
|
<div class="volume-control">
|
||||||
<input
|
<input
|
||||||
id="volume"
|
id="volume"
|
||||||
type="range"
|
type="range"
|
||||||
min="0"
|
min="0"
|
||||||
max="100"
|
max="100"
|
||||||
[value]="volume()"
|
[value]="volume()"
|
||||||
(input)="onVolumeChange($event)"
|
(input)="onVolumeChange($event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
|||||||
isPlayerReady = signal(false);
|
isPlayerReady = signal(false);
|
||||||
isPlaying = signal(false);
|
isPlaying = signal(false);
|
||||||
nowPlayingTitle = signal<string>('');
|
nowPlayingTitle = signal<string>('');
|
||||||
|
volume = signal(50)
|
||||||
|
|
||||||
constructor(private deviceService: ViewportService) {}
|
constructor(private deviceService: ViewportService) {}
|
||||||
|
|
||||||
@@ -33,16 +34,40 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (window.YT && window.YT.Player) {
|
void this.loadYouTubeApi().then(() => {
|
||||||
this.createPlayer();
|
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() {
|
createPlayer() {
|
||||||
this.player = new window.YT.Player('youtube-player', {
|
this.player = new window.YT.Player('youtube-player', {
|
||||||
height: '0', // or something minimal
|
height: '0',
|
||||||
width: '0',
|
width: '0',
|
||||||
playerVars: {
|
playerVars: {
|
||||||
listType: 'playlist',
|
listType: 'playlist',
|
||||||
@@ -54,7 +79,6 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
|||||||
onReady: () => {
|
onReady: () => {
|
||||||
this.isPlayerReady.set(true);
|
this.isPlayerReady.set(true);
|
||||||
this.player.setVolume(this.volume());
|
this.player.setVolume(this.volume());
|
||||||
console.log('YouTube Player Ready');
|
|
||||||
|
|
||||||
const iframe = document.getElementById('youtube-player') as HTMLIFrameElement | null;
|
const iframe = document.getElementById('youtube-player') as HTMLIFrameElement | null;
|
||||||
if (iframe) {
|
if (iframe) {
|
||||||
@@ -70,7 +94,13 @@ export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
|||||||
},
|
},
|
||||||
onStateChange: (event: any) => {
|
onStateChange: (event: any) => {
|
||||||
if (event.data === window.YT.PlayerState.PLAYING) {
|
if (event.data === window.YT.PlayerState.PLAYING) {
|
||||||
|
this.isPlaying.set(true);
|
||||||
this.updateNowPlayingTitle();
|
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) {
|
onVolumeChange(event: Event) {
|
||||||
const target = event.target as HTMLInputElement;
|
const target = event.target as HTMLInputElement;
|
||||||
const newVolume = parseInt(target.value, 10);
|
const newVolume = parseInt(target.value, 10);
|
||||||
|
|
||||||
|
this.volume.set(newVolume);
|
||||||
|
|
||||||
if (this.isPlayerReady() && this.player?.setVolume) {
|
if (this.isPlayerReady() && this.player?.setVolume) {
|
||||||
this.player.setVolume(newVolume);
|
this.player.setVolume(newVolume);
|
||||||
this.volume.set(newVolume);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script src="https://www.youtube.com/iframe_api"></script>
|
|
||||||
<title>itzMiney's Home</title>
|
<title>itzMiney's Home</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<base href="/">
|
<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="32x32" href="/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
<link rel="manifest" href="/site.webmanifest">
|
<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>
|
</head>
|
||||||
<body class="mat-typography">
|
<body class="mat-typography">
|
||||||
<app-root></app-root>
|
<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 {
|
html, body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
Reference in new issue
Block a user