-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerBar.svelte
More file actions
96 lines (87 loc) · 2.45 KB
/
PlayerBar.svelte
File metadata and controls
96 lines (87 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<script>
// @ts-nocheck
import { get } from "svelte/store";
import { isPlaying, currentSong, playOrPauseSong, playPercentage, isLoading } from "../scripts/playbackService";
import { getImageUrl } from "../scripts/api";
$: $currentSong;
$: $isPlaying;
$: $playPercentage;
$: $isLoading;
function togglePlay() {
if(get(currentSong)){
playOrPauseSong(get(currentSong).id);
}
}
</script>
<div class="container-fluid player-bar mb-2">
<div class="row space-between">
<div class="image-placeholder col-2 col-md-2 col-lg-2" style="--url: url({getImageUrl($currentSong.thumbnail_path)});">
</div>
<div class="col-8 col-md-8 col-lg-9" style="background: linear-gradient(to right, #1DB954 {$playPercentage}%, #2c2c2c {$playPercentage}%);">
<button type="button" class="btn clickable-text" data-bs-toggle="{$currentSong ? "modal" : ""}" data-bs-target="{$currentSong ? "#songControlModal" : ""}">
{#if $currentSong}
{$currentSong.name}
{:else}
No song playing
{/if}
</button>
</div>
<div class="col-2 col-md-2 col-lg-1">
<button on:click={togglePlay} class="btn play-button w-100">
{#if $currentSong && $isPlaying && !$isLoading}
<i class="fa-solid fa-pause"></i>
{:else if !$isLoading && !$isPlaying}
<i class="fa-solid fa-play"></i>
{:else if $isLoading}
<i class="fa-solid fa-spinner fa-spin"></i>
{/if}
</button>
</div>
</div>
</div>
<style>
.player-bar .clickable-text {
font-size: 0.65rem;
max-height: 2.8rem;
min-height: 2.8rem;
width: 100%;
font-weight: bold;
color: white;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 2px;
}
.player-bar {
background-color: transparent;
}
.image-placeholder{
background-image: var(--url);
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.play-button {
font-weight: bolder;
font-size: 1.4rem;
width: 100%;
height: 100%;
display: block !important;
margin: 0;
color: #1DB954;
font-weight: bolder;
background-color: #2c2c2c;
border: none !important;
border-radius: 0 !important;
}
.player-bar .col-8 {
padding: 0 !important;
}
.player-bar .col-2 {
padding: 0 !important;
}
</style>