mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-09-22 05:50:48 +02:00
feat(dashboard): implement player
This commit is contained in:
parent
223c13ad99
commit
124f9c15a8
17 changed files with 545 additions and 254 deletions
|
@ -5,12 +5,14 @@ import { UserService } from './users.service';
|
|||
import { ElectricityService } from './electricity.service';
|
||||
import { StateService } from './state.service';
|
||||
import { SmartTableService } from './smart-table.service';
|
||||
import { PlayerService } from './player.service';
|
||||
|
||||
const SERVICES = [
|
||||
UserService,
|
||||
ElectricityService,
|
||||
StateService,
|
||||
SmartTableService,
|
||||
PlayerService,
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
67
src/app/@core/data/player.service.ts
Normal file
67
src/app/@core/data/player.service.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import 'rxjs/add/observable/of';
|
||||
|
||||
export class Track {
|
||||
name: string;
|
||||
artist: string;
|
||||
url: string;
|
||||
cover: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class PlayerService {
|
||||
current: number;
|
||||
playlist: Track[] = [
|
||||
{
|
||||
name: 'Don\'t Wanna Fight',
|
||||
artist: 'Alabama Shakes',
|
||||
url: 'https://p.scdn.co/mp3-preview/6156cdbca425a894972c02fca9d76c0b70e001af',
|
||||
cover: './assets/images/cover1.jpg',
|
||||
},
|
||||
{
|
||||
name: 'Good Vibrations',
|
||||
artist: 'Marky Mark And The Funky Bunch',
|
||||
url: 'https://p.scdn.co/mp3-preview/d502c5fa63d28442808779a3832524b4fb1c44fa',
|
||||
cover: './assets/images/cover2.jpg',
|
||||
},
|
||||
{
|
||||
name: 'Come Together',
|
||||
artist: 'Beatles',
|
||||
url: 'https://p.scdn.co/mp3-preview/83090a4db6899eaca689ae35f69126dbe65d94c9',
|
||||
cover: './assets/images/cover3.jpg',
|
||||
},
|
||||
];
|
||||
|
||||
random(): Track {
|
||||
this.current = Math.floor(Math.random() * this.playlist.length);
|
||||
return this.playlist[this.current];
|
||||
}
|
||||
|
||||
next(): Track {
|
||||
return this.getNextTrack();
|
||||
}
|
||||
|
||||
prev() {
|
||||
return this.getPrevTrack();
|
||||
}
|
||||
|
||||
private getNextTrack(): Track {
|
||||
if (this.current === this.playlist.length - 1) {
|
||||
this.current = 0;
|
||||
} else {
|
||||
this.current++;
|
||||
}
|
||||
|
||||
return this.playlist[this.current];
|
||||
}
|
||||
|
||||
private getPrevTrack(): Track {
|
||||
if (this.current === 0) {
|
||||
this.current = this.playlist.length - 1;
|
||||
} else {
|
||||
this.current--;
|
||||
}
|
||||
|
||||
return this.playlist[this.current];
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
export * from './capitalize.pipe';
|
||||
export * from './plural.pipe';
|
||||
export * from './round.pipe';
|
||||
export * from './timing.pipe';
|
||||
|
|
18
src/app/@theme/pipes/timing.pipe.ts
Normal file
18
src/app/@theme/pipes/timing.pipe.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({ name: 'timing' })
|
||||
export class TimingPipe implements PipeTransform {
|
||||
transform(time: number): string {
|
||||
if (time) {
|
||||
const minutes = Math.floor(time / 60);
|
||||
const seconds = Math.floor(time % 60);
|
||||
return `${this.initZero(minutes)}${minutes}:${this.initZero(seconds)}${seconds}`;
|
||||
}
|
||||
|
||||
return '00:00';
|
||||
}
|
||||
|
||||
private initZero(time: number): string {
|
||||
return time < 10 ? '0' : '';
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import {
|
|||
ThemeSettingsComponent,
|
||||
TinyMCEComponent,
|
||||
} from './components';
|
||||
import { CapitalizePipe, PluralPipe, RoundPipe } from './pipes';
|
||||
import { CapitalizePipe, PluralPipe, RoundPipe, TimingPipe } from './pipes';
|
||||
import {
|
||||
OneColumnLayoutComponent,
|
||||
SampleLayoutComponent,
|
||||
|
@ -62,7 +62,12 @@ const COMPONENTS = [
|
|||
TwoColumnsLayoutComponent,
|
||||
];
|
||||
|
||||
const PIPES = [CapitalizePipe, PluralPipe, RoundPipe];
|
||||
const PIPES = [
|
||||
CapitalizePipe,
|
||||
PluralPipe,
|
||||
RoundPipe,
|
||||
TimingPipe,
|
||||
];
|
||||
|
||||
const NB_THEME_PROVIDERS = [
|
||||
...NbThemeModule.forRoot(
|
||||
|
|
|
@ -1,58 +1,46 @@
|
|||
<div class="player">
|
||||
<div class="player-card-header">
|
||||
<div class="player-menu">
|
||||
<i class="ion-navicon"></i>
|
||||
</div>
|
||||
<div class="playlist-name">
|
||||
<span>My Playlist</span>
|
||||
<div class="header">My Playlist</div>
|
||||
|
||||
<div class="body">
|
||||
|
||||
<div class="cover">
|
||||
<img [src]="track.cover">
|
||||
<div class="details">
|
||||
<h4>{{ track.name }}</h4>
|
||||
<span class="artist">{{ track.artist }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="player-cover">
|
||||
<div class="album-image"></div>
|
||||
<div class="artist-details">
|
||||
<span class="artist-name">Kendrick Lamar</span>
|
||||
<span class="song-name">DNA.</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-wrap">
|
||||
<input type="range" class="progress" [value]="getProgress()" min="0" max="100" step="0.01"
|
||||
(input)="setProgress(duration.value)" #duration>
|
||||
<div class="progress-foreground" [style.width.%]="getProgress()"></div>
|
||||
</div>
|
||||
<div class="player-progress">
|
||||
<div class="status"></div>
|
||||
|
||||
<div class="timing">
|
||||
<small class="current">{{ player.currentTime | timing }}</small>
|
||||
<small class="remaining">- {{ player.duration - player.currentTime | timing }}</small>
|
||||
</div>
|
||||
<div class="player-commands">
|
||||
<div class="prev">
|
||||
<i class="ion-ios-skipbackward"></i>
|
||||
</div>
|
||||
<div class="play">
|
||||
<i class="ion-ios-play"></i>
|
||||
</div>
|
||||
<div class="next">
|
||||
<i class="ion-ios-skipforward"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="player-volume">
|
||||
<div class="minus" (click)="minus()">
|
||||
<i class="ion-ios-minus-outline"></i>
|
||||
</div>
|
||||
<div class="volume-items">
|
||||
<div class="volume-item" *ngFor="let v of volume"
|
||||
(click)="selectedVolume = v"
|
||||
[class.active]="v < selectedVolume"
|
||||
[class.selected]="v === selectedVolume"></div>
|
||||
</div>
|
||||
<div class="plus" (click)="plus()">
|
||||
<i class="ion-ios-plus-outline"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="player-playlist-commands">
|
||||
<div class="btn-group btn-group-full-width" data-toggle="buttons">
|
||||
<label class="btn btn-primary" [class.active]="playlistCommandsModel.left">
|
||||
<input type="checkbox" [(ngModel)]="playlistCommandsModel.left"/> <i class="ion-plus-round"></i>
|
||||
</label>
|
||||
<label class="btn btn-primary" [class.active]="playlistCommandsModel.middle">
|
||||
<input type="checkbox" [(ngModel)]="playlistCommandsModel.middle"/> <i class="ion-plus-round"></i>
|
||||
</label>
|
||||
<label class="btn btn-primary" [class.active]="playlistCommandsModel.right">
|
||||
<input type="checkbox" [(ngModel)]="playlistCommandsModel.right"/> <i class="ion-plus-round"></i>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<i class="nb-shuffle shuffle" [class.active]="shuffle" (click)="toggleShuffle()"></i>
|
||||
<i class="nb-skip-backward prev" (click)="prev()"></i>
|
||||
<i class="play" [class.nb-play]="player.paused" [class.nb-pause]="!player.paused" (click)="playPause()"></i>
|
||||
<i class="nb-skip-forward next" (click)="next()"></i>
|
||||
<i class="nb-loop loop" [class.active]="player.loop" (click)="toggleLoop()"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
|
||||
<div class="volume">
|
||||
<i class="nb-volume-mute quiet"></i>
|
||||
<div class="progress-wrap">
|
||||
<input type="range" class="progress" [value]="getVolume()" max="100"
|
||||
(input)="setVolume(volume.value)" #volume>
|
||||
<div class="progress-foreground" [style.width.%]="getVolume()"></div>
|
||||
</div>
|
||||
<i class="nb-volume-high loud"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,183 +1,280 @@
|
|||
@import '../../../@theme/styles/themes';
|
||||
@import '~bootstrap/scss/mixins/breakpoints';
|
||||
@import '~@nebular/theme/components/card/card.component.theme';
|
||||
@import '~@nebular/theme/styles/global/bootstrap/breakpoints';
|
||||
@import '~@nebular/theme/styles/core/mixins';
|
||||
|
||||
@include nb-install-component() {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
border-left: 2px solid nb-theme(separator);
|
||||
|
||||
.player {
|
||||
flex: 1;
|
||||
.header {
|
||||
@include nb-card-header();
|
||||
}
|
||||
|
||||
// TODO: Replace with the card header styles mixin
|
||||
.player-card-header {
|
||||
display: flex;
|
||||
line-height: 2rem;
|
||||
font-size: 1.25rem;
|
||||
font-family: nb-theme(font-secondary);
|
||||
font-weight: nb-theme(font-weight-bolder);
|
||||
color: nb-theme(color-fg-heading);
|
||||
padding: 1.25rem;
|
||||
.body {
|
||||
padding: nb-theme(card-padding);
|
||||
}
|
||||
|
||||
.player-menu {
|
||||
font-size: 2.5rem;
|
||||
margin-right: 1.25rem;
|
||||
margin-top: -0.25rem;
|
||||
}
|
||||
.footer {
|
||||
padding: nb-theme(card-padding);
|
||||
border-top: 1px solid nb-theme(separator);
|
||||
}
|
||||
|
||||
.cover {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
|
||||
img {
|
||||
height: 10rem;
|
||||
width: 10rem;
|
||||
border-radius: nb-theme(radius) / 2;
|
||||
}
|
||||
|
||||
.player-cover {
|
||||
background: #363175;
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
.details {
|
||||
text-align: center;
|
||||
padding: 1.75rem 0 1.5rem;
|
||||
|
||||
.album-image {
|
||||
background: url('./~/assets/images/damn.jpg');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
height: 94px;
|
||||
width: 30%;
|
||||
box-shadow: nb-theme(card-shadow);
|
||||
}
|
||||
|
||||
.artist-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
margin-left: 1.25rem;
|
||||
|
||||
.artist-name {
|
||||
color: nb-theme(color-fg-heading);
|
||||
font-size: 1.5rem;
|
||||
font-family: nb-theme(font-secondary);
|
||||
font-weight: nb-theme(font-weight-bold);
|
||||
}
|
||||
|
||||
.song-name {
|
||||
font-family: nb-theme(font-main);
|
||||
font-size: 1.125rem;
|
||||
color: nb-theme(color-fg);
|
||||
}
|
||||
.artist {
|
||||
color: nb-theme(color-fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.player-progress {
|
||||
background-color: #2c2961;
|
||||
.progress-wrap {
|
||||
position: relative;
|
||||
height: 1rem;
|
||||
margin: 0 -#{nb-theme(card-padding)};
|
||||
|
||||
.progress-foreground {
|
||||
background-color: nb-theme(color-success);
|
||||
height: 2px;
|
||||
position: absolute;
|
||||
margin-top: calc(0.75rem - 1px);
|
||||
width: 100px;
|
||||
|
||||
.status {
|
||||
background-color: #0088ff;
|
||||
height: 2px;
|
||||
width: 70%;
|
||||
box-shadow: 0 4px 8px 0 rgba(33, 7, 77, 0.4), 0 0 12px 0 rgba(51, 139, 255, 0.4);
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
border-radius: 50%;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
right: 0;
|
||||
box-shadow: 0 0 18px 0 rgba(255, 255, 255, 0.4);
|
||||
top: -0.5rem;
|
||||
}
|
||||
@include nb-for-theme(cosmic) {
|
||||
background-color: nb-theme(link-color-active);
|
||||
}
|
||||
}
|
||||
|
||||
.player-commands {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
font-size: 4rem;
|
||||
color: nb-theme(color-fg-heading);
|
||||
padding: 2.5rem 0;
|
||||
border-bottom: 1px solid nb-theme(separator);
|
||||
.progress {
|
||||
-webkit-appearance: none;
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
height: 1.5rem;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
|
||||
.prev {
|
||||
color: nb-theme(color-fg);
|
||||
}
|
||||
}
|
||||
|
||||
.player-volume {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
font-size: 4rem;
|
||||
color: nb-theme(color-fg);
|
||||
padding: 2rem 0;
|
||||
border-bottom: 1px solid nb-theme(separator);
|
||||
|
||||
.minus:hover {
|
||||
color: nb-theme(color-fg-heading);
|
||||
}
|
||||
|
||||
.plus:hover {
|
||||
color: nb-theme(color-fg-heading);
|
||||
}
|
||||
|
||||
.volume-items {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
font-size: 2rem;
|
||||
margin: 0 -4rem;
|
||||
|
||||
.volume-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.volume-item::before {
|
||||
content: '';
|
||||
width: 4px;
|
||||
background-color: nb-theme(separator);
|
||||
height: 30%;
|
||||
border-radius: 1rem;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.volume-item:not(:last-child)::before {
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
.volume-item.active::before {
|
||||
background-image: linear-gradient(to right, #4f6fff, #00ccff);
|
||||
box-shadow: 0 4px 10px 0 rgba(33, 7, 77, 0.5), 0 2px 12px 0 rgba(0, 136, 255, 0.7);
|
||||
}
|
||||
|
||||
.volume-item.selected::before {
|
||||
background-color: white;
|
||||
height: 40%;
|
||||
box-shadow: 0 0 18px 0 rgba(255, 255, 255, 0.68);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.player-playlist-commands {
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
.player-playlist-commands > .btn-group {
|
||||
height: 100%;
|
||||
|
||||
.btn {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
@include install-thumb() {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
border-radius: 50%;
|
||||
background: nb-theme(color-success);
|
||||
cursor: pointer;
|
||||
margin-top: calc(-0.5rem + 1px);
|
||||
border: none;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.btn.active {
|
||||
background-color: nb-theme(card-bg);
|
||||
color: nb-theme(color-fg);
|
||||
@include install-track() {
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
cursor: pointer;
|
||||
background: nb-theme(separator);
|
||||
}
|
||||
|
||||
.btn:first-child {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
@include nb-for-theme(cosmic) {
|
||||
@include install-thumb() {
|
||||
background: nb-theme(link-color-active);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.timing {
|
||||
padding-top: 0.25rem;
|
||||
margin: 0 -0.25rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: nb-theme(color-fg);
|
||||
}
|
||||
|
||||
.controls {
|
||||
// TODO fix controls font-size when complete icons fo
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 0.875rem 1.25rem 0;
|
||||
|
||||
i {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.shuffle, .loop {
|
||||
font-size: 1.25rem;
|
||||
color: nb-theme(color-fg);
|
||||
|
||||
&.active {
|
||||
color: nb-theme(color-success);
|
||||
|
||||
@include nb-for-theme(cosmic) {
|
||||
color: nb-theme(link-color-active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.prev, .next {
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
border: 2px solid nb-theme(separator);
|
||||
border-radius: 50%;
|
||||
|
||||
&::before {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.play {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.volume {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 0 1.25rem;
|
||||
position: relative;
|
||||
|
||||
.progress-wrap {
|
||||
height: 2.25rem;
|
||||
margin: 0;
|
||||
width: 80%;
|
||||
|
||||
.progress-foreground {
|
||||
margin-top: calc(1rem + 1px);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.btn:last-child {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: nb-theme(card-border-radius);
|
||||
.progress {
|
||||
height: 2.25rem;
|
||||
|
||||
@include install-thumb() {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 2px 6px 0 rgba(61, 61, 61, 0.2);
|
||||
border: solid 1px rgba(0, 0, 0, 0.1);
|
||||
margin-top: calc(-0.875rem + 1px);
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.quite, .loud {
|
||||
color: nb-theme(color-fg);
|
||||
}
|
||||
|
||||
.quite {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.loud {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@include media-breakpoint-down(lg) {
|
||||
border: none;
|
||||
|
||||
.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.controls, .volume {
|
||||
max-width: 20rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
&.collapsed {
|
||||
|
||||
.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cover {
|
||||
height: 4.5rem;
|
||||
flex-direction: row;
|
||||
margin: 0;
|
||||
|
||||
img {
|
||||
height: 4.5rem;
|
||||
width: 4.5rem;
|
||||
margin: 0;
|
||||
border-radius: 0 0 0 nb-theme(radius);
|
||||
}
|
||||
|
||||
.details {
|
||||
margin-left: 0.875rem;
|
||||
text-align: left;
|
||||
padding: 0;
|
||||
|
||||
h4 {
|
||||
margin-bottom: 0.125rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.progress-wrap {
|
||||
width: calc(100% - 6rem);
|
||||
align-self: flex-start;
|
||||
position: absolute;
|
||||
margin-top: calc(-0.75rem + 1px);
|
||||
margin-left: 4.5rem;
|
||||
}
|
||||
|
||||
.timing {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.controls {
|
||||
margin: 0;
|
||||
|
||||
.prev, .shuffle, .repeat {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.next {
|
||||
font-size: 1.8rem;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.play {
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.volume {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Range } from 'immutable';
|
||||
import { Component, HostBinding, Input } from '@angular/core';
|
||||
import { PlayerService, Track } from '../../../@core/data/player.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-player',
|
||||
|
@ -7,24 +8,84 @@ import { Range } from 'immutable';
|
|||
templateUrl: './player.component.html',
|
||||
})
|
||||
export class PlayerComponent {
|
||||
@Input()
|
||||
@HostBinding('class.collapsed')
|
||||
collapsed: boolean;
|
||||
|
||||
selectedVolume: number = 10;
|
||||
volume = Range(0, 30, 1);
|
||||
playlistCommandsModel = {
|
||||
left: true,
|
||||
middle: true,
|
||||
right: false,
|
||||
};
|
||||
track: Track;
|
||||
player: HTMLAudioElement;
|
||||
shuffle: boolean;
|
||||
|
||||
minus() {
|
||||
if (this.selectedVolume !== 0) {
|
||||
this.selectedVolume--;
|
||||
constructor(private playerService: PlayerService) {
|
||||
this.track = this.playerService.random();
|
||||
this.createPlayer();
|
||||
}
|
||||
|
||||
prev() {
|
||||
if (this.shuffle) {
|
||||
this.track = this.playerService.random();
|
||||
} else {
|
||||
this.track = this.playerService.prev();
|
||||
}
|
||||
|
||||
this.reload();
|
||||
}
|
||||
|
||||
next() {
|
||||
if (this.shuffle) {
|
||||
this.track = this.playerService.random();
|
||||
} else {
|
||||
this.track = this.playerService.next();
|
||||
}
|
||||
|
||||
this.reload();
|
||||
}
|
||||
|
||||
playPause() {
|
||||
if (this.player.paused) {
|
||||
this.player.play();
|
||||
} else {
|
||||
this.player.pause();
|
||||
}
|
||||
}
|
||||
|
||||
plus() {
|
||||
if (this.selectedVolume !== 29) {
|
||||
this.selectedVolume++;
|
||||
}
|
||||
toggleShuffle() {
|
||||
this.shuffle = !this.shuffle;
|
||||
}
|
||||
|
||||
toggleLoop() {
|
||||
this.player.loop = !this.player.loop;
|
||||
}
|
||||
|
||||
setVolume(volume: number) {
|
||||
this.player.volume = volume / 100;
|
||||
}
|
||||
|
||||
getVolume(): number {
|
||||
return this.player.volume * 100;
|
||||
}
|
||||
|
||||
setProgress(duration: number) {
|
||||
this.player.currentTime = this.player.duration * duration / 100;
|
||||
}
|
||||
|
||||
getProgress(): number {
|
||||
return this.player.currentTime / this.player.duration * 100 || 0;
|
||||
}
|
||||
|
||||
private createPlayer() {
|
||||
this.player = new Audio();
|
||||
this.player.onended = () => this.next();
|
||||
this.setTrack();
|
||||
}
|
||||
|
||||
private reload() {
|
||||
this.setTrack();
|
||||
this.player.play();
|
||||
}
|
||||
|
||||
private setTrack() {
|
||||
this.player.src = this.track.url;
|
||||
this.player.load();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="rooms-card-header">Room Management</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" [attr.viewBox]="viewBox"
|
||||
preserveAspectRatio="xMidYMid">
|
||||
<div class="header">Room Management</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
class="room-selector" [attr.viewBox]="viewBox" preserveAspectRatio="xMidYMid">
|
||||
<defs>
|
||||
|
||||
<filter id="f2" x="-50%" y="-50%" width="200%" height="200%">
|
||||
|
|
|
@ -2,19 +2,6 @@
|
|||
@import '~@nebular/theme/components/card/card.component.theme';
|
||||
|
||||
@include nb-install-component() {
|
||||
:host {
|
||||
display: block;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
svg {
|
||||
display:block;
|
||||
width: 100%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.stroke-pattern {
|
||||
fill: none;
|
||||
stroke: #bdc4cd;
|
||||
|
@ -70,11 +57,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
.rooms-card-header {
|
||||
.header {
|
||||
@include nb-card-header();
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.room-selector {
|
||||
width: 80%;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@include nb-for-theme(cosmic) {
|
||||
.stroke-pattern, .stroked-element, .room-border {
|
||||
stroke: #a1a1e5;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, EventEmitter, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-room-selector',
|
||||
|
@ -6,12 +6,11 @@ import { Component } from '@angular/core';
|
|||
styleUrls: ['./room-selector.component.scss'],
|
||||
})
|
||||
export class RoomSelectorComponent {
|
||||
@Output() select: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
selectedRoom: null;
|
||||
|
||||
sortedRooms = [];
|
||||
|
||||
viewBox = '-20 -20 618.88 407.99';
|
||||
|
||||
roomSvg = {
|
||||
borders: [{
|
||||
d: 'M186.21,130.05H216.37V160H186.21Z',
|
||||
|
@ -72,6 +71,7 @@ export class RoomSelectorComponent {
|
|||
}
|
||||
|
||||
selectRoom(roomNumber) {
|
||||
this.select.emit(roomNumber);
|
||||
this.selectedRoom = roomNumber;
|
||||
this.sortRooms();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,46 @@
|
|||
@import '../../../@theme/styles/themes';
|
||||
@import '~bootstrap/scss/mixins/breakpoints';
|
||||
@import '~@nebular/theme/styles/global/bootstrap/breakpoints';
|
||||
|
||||
@include nb-install-component() {
|
||||
|
||||
ngx-room-selector {
|
||||
width: 65%;
|
||||
background-image: nb-theme(radial-gradient);
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
ngx-player {
|
||||
flex: 1;
|
||||
box-shadow: nb-theme(card-shadow);
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
nb-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
@include media-breakpoint-down(xl) {
|
||||
&.expanded ngx-room-selector {
|
||||
display: none;
|
||||
}
|
||||
|
||||
ngx-room-selector, ngx-player {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
nb-card {
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
||||
.collapse {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-self: center;
|
||||
font-size: 3rem;
|
||||
color: nb-theme(color-fg);
|
||||
transition: display 0.3s ease;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,46 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, HostBinding } from '@angular/core';
|
||||
import { NbMediaBreakpoint } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-rooms',
|
||||
styleUrls: ['./rooms.component.scss'],
|
||||
template: `
|
||||
<nb-card size="large">
|
||||
<ngx-room-selector></ngx-room-selector>
|
||||
<ngx-player></ngx-player>
|
||||
<i (click)="collapse()" class="ion-ios-arrow-down collapse" [hidden]="isCollapsed()"></i>
|
||||
<ngx-room-selector (select)="select($event)"></ngx-room-selector>
|
||||
<ngx-player [collapsed]="isCollapsed()"></ngx-player>
|
||||
</nb-card>
|
||||
`,
|
||||
})
|
||||
export class RoomsComponent {
|
||||
|
||||
@HostBinding('class.expanded')
|
||||
private expanded: boolean;
|
||||
private selected: number;
|
||||
|
||||
select(roomNumber) {
|
||||
if (this.isSelected(roomNumber)) {
|
||||
this.expand();
|
||||
} else {
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
this.selected = roomNumber;
|
||||
}
|
||||
|
||||
expand() {
|
||||
this.expanded = true;
|
||||
}
|
||||
|
||||
collapse() {
|
||||
this.expanded = false;
|
||||
}
|
||||
|
||||
isCollapsed() {
|
||||
return !this.expanded;
|
||||
}
|
||||
|
||||
private isSelected(roomNumber): boolean {
|
||||
return this.selected === roomNumber;
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/assets/images/cover1.jpg
Normal file
BIN
src/assets/images/cover1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
src/assets/images/cover2.jpg
Normal file
BIN
src/assets/images/cover2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 KiB |
BIN
src/assets/images/cover3.jpg
Normal file
BIN
src/assets/images/cover3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
Before Width: | Height: | Size: 89 KiB |
Loading…
Add table
Add a link
Reference in a new issue