refactored audio-player component
This commit is contained in:
1 parent
357e1b6cf3
commit
b396728db8
3 files changed
+29
-6
No files matched your search
@@ -44,12 +44,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.audio-player {
|
.audio-player {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 10px;
|
width: 340px;
|
||||||
left: 20px;
|
height: 130px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
z-index: 10;
|
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 {
|
.audio-player h3 {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="audio-player">
|
<div class="audio-player" [ngClass]="{ mobile: isMobile }">
|
||||||
<div id="youtube-player"></div>
|
<div id="youtube-player"></div>
|
||||||
<h3>{{ nowPlayingTitle() }}</h3>
|
<h3>{{ nowPlayingTitle() }}</h3>
|
||||||
<div class="controls">
|
<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 {
|
declare global {
|
||||||
@@ -10,16 +12,26 @@ declare global {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-audio-player',
|
selector: 'app-audio-player',
|
||||||
imports: [],
|
imports: [
|
||||||
|
NgClass
|
||||||
|
],
|
||||||
templateUrl: './audio-player.component.html',
|
templateUrl: './audio-player.component.html',
|
||||||
styleUrl: './audio-player.component.css'
|
styleUrl: './audio-player.component.css'
|
||||||
})
|
})
|
||||||
export class AudioPlayerComponent implements AfterViewInit {
|
export class AudioPlayerComponent implements AfterViewInit, OnInit {
|
||||||
|
isMobile: boolean = false;
|
||||||
private player: any;
|
private player: any;
|
||||||
|
|
||||||
isPlayerReady = signal(false);
|
isPlayerReady = signal(false);
|
||||||
isPlaying = signal(false);
|
isPlaying = signal(false);
|
||||||
nowPlayingTitle = signal<string>('');
|
nowPlayingTitle = signal<string>('');
|
||||||
|
|
||||||
|
constructor(private deviceService: DeviceDetectorService) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.isMobile = this.deviceService.isMobile;
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (window.YT && window.YT.Player) {
|
if (window.YT && window.YT.Player) {
|
||||||
this.createPlayer();
|
this.createPlayer();
|
||||||
|
|||||||
Reference in new issue
Block a user