refactored audio-player component

This commit is contained in:
itzMiney committed 2026-03-17 01:45:09 +01:00
1 parent 357e1b6cf3
commit b396728db8
3 files changed
+29 -6

No files matched your search

@@ -44,12 +44,23 @@
}
.audio-player {
display: flex;
flex-direction: column;
position: fixed;
bottom: 10px;
left: 20px;
width: 340px;
height: 130px;
bottom: 0;
left: 0;
align-items: center;
justify-content: center;
z-index: 10;
}
.audio-player.mobile {
background: linear-gradient(to top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
width: 100%;
}
.audio-player h3 {
margin-left: 15px;
text-align: center;
@@ -1,4 +1,4 @@
<div class="audio-player">
<div class="audio-player" [ngClass]="{ mobile: isMobile }">
<div id="youtube-player"></div>
<h3>{{ nowPlayingTitle() }}</h3>
<div class="controls">
@@ -1,4 +1,6 @@
import {Component, AfterViewInit, signal} from '@angular/core';
import {Component, AfterViewInit, signal, OnInit} from '@angular/core';
import {DeviceDetectorService} from '../services/device-detector.service';
import {NgClass} from '@angular/common';
declare global {
@@ -10,16 +12,26 @@ declare global {
@Component({
selector: 'app-audio-player',
imports: [],
imports: [
NgClass
],
templateUrl: './audio-player.component.html',
styleUrl: './audio-player.component.css'
})
export class AudioPlayerComponent implements AfterViewInit {
export class AudioPlayerComponent implements AfterViewInit, OnInit {
isMobile: boolean = false;
private player: any;
isPlayerReady = signal(false);
isPlaying = signal(false);
nowPlayingTitle = signal<string>('');
constructor(private deviceService: DeviceDetectorService) {}
ngOnInit() {
this.isMobile = this.deviceService.isMobile;
}
ngAfterViewInit() {
if (window.YT && window.YT.Player) {
this.createPlayer();